Project 563: Spinning Blocks

4. Write Script to Make Your Block Spin

Steps

1. Label the block

Create a new local variable called 'block' to represent your spinning block.
local block = script.Parent

2. Create a Rotation Variable

Make a new local variable called 'rotation' and set it equal to 0. This means that our block will start at a rotation of 0.
local rotation = 0

3. Create a forever loop

Using 'while true do' create a loop that will run forever. Don't forget to hit 'return/enter' on your keyboard after 'do' to get your end-statement.
while true do end

4. Wait between rotations

To make the block look like it's spinning smoothly, we will have it wait 0.001 seconds between each turn
wait(0.001)

5. Get the orientation of the block

Access the orientation of the block using block.Orientation.
block.Orientation

6. Set the new orientation of the block

Create a new Vector3 that uses your 'rotation' variable to set the orientation of your block.
block.Orientation = Vector3.new(0, rotation, 0)

7. Increase the rotation variable by 1

Add 1 to the rotation variable. Next time the loop runs the orientation of your block will get set to a rotation that is turned 1 degree more than what you set it to in the previous line, making it loop like it is spinning.
rotation = rotation + 1