This tutorial assumes you already have a kill brick in your game. Click here to learn how to make a kill brick.
First, make sure the Anchored property of your kill brick is set to true. Insert a Script inside of the kill brick that you want to spin. We will need to make a variable for the kill brick so that we can make it spin using code. The script is inside of the kill brick, meaning that the Parent property of the script is the kill brick. Therefore, we can reference the kill brick using the following line of code:
local killBrick = script.Parent
Because we want the kill brick to spin continuously, we need to use a while true do loop which allows us to run a segment of code forever. When using a while true do loop, it is important to include a task.wait()
statement as the game will crash otherwise. Inside of the loop, we will write code that rotates the kill brick by a very small amount. Because this code is inside the loop, the kill brick will rotate by a small amount several times per second, which makes the kill brick spin.
local killBrick = script.Parent
while true do
task.wait()
killBrick.CFrame = killBrick.CFrame * CFrame.Angles(0, 0.05, 0)
end
If you now play the game, the kill brick should spin.