Sign in
Home
Online Classes
Instructors
Tutorials
☰
Register
Sign in
Online Classes
Instructors
Tutorials
1. Angles and Axes (c)
2. Set Up Your Project
3. Add a Script to SpinningBlock
4. Write Script to Make Your Block Spin
5. Save and Test
6. Make a Pinwheel
7. Make a Block Rotate in a Different Direction
8. Consolidate Your Code (Optional)
Project 563: Spinning Blocks
4. Write Script to Make Your Block Spin
Starting point file for this challenge
Hint: show steps
Steps
1. Label the block
Hint: show details
Create a new local variable called 'block' to represent your spinning block.
local block = script.Parent
Hint: show image
Hint: show code
2. Create a Rotation Variable
Hint: show details
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
Hint: show image
Hint: show code
3. Create a forever loop
Hint: show details
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
Hint: show code
4. Wait between rotations
Hint: show details
To make the block look like it's spinning smoothly, we will have it wait 0.001 seconds between each turn
wait(0.001)
Hint: show code
5. Get the orientation of the block
Hint: show details
Access the orientation of the block using
block.Orientation
.
block.Orientation
Hint: show code
6. Set the new orientation of the block
Hint: show details
Create a new Vector3 that uses your 'rotation' variable to set the orientation of your block.
block.Orientation = Vector3.new(0, rotation, 0)
Hint: show code
7. Increase the rotation variable by 1
Hint: show details
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
Hint: show code
×
×
Provide your email address for immediate project access
Email
Check your email for instructions on how to create a full DA account