Lesson · with Snap

Your First Script

Write Lua that makes a part spin forever. Then change one number and see what happens.

You need

  • Roblox Studio
  • A mouse is strongly recommended

Steps

  1. Make a spinner

    Insert a Part, anchor it and name it Spinner in Explorer.

  2. Add a Script

    Hover over Spinner in Explorer, click +, and choose Script.

  3. Type the code

    Replace the starter line with: while true do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, 0.05, 0) task.wait() end

  4. Change one thing

    Change 0.05 to 0.2. Press Play. What changed? Now try moving 0.05 into the first slot.

Build task

Spinning hazard

Turn your spinner into an obstacle the player must time a jump around.

Finish line: A scripted part that moves when the game runs.

Check your understanding

1. In this script, what does script.Parent mean?
2. What happens if you make 0.05 bigger?
Guest mode: your result is saved on this device only.