Two ways to say the same thing
Every block script is really a Luau script underneath. Today you'll build with blocks, look at the Luau it makes, and then edit the Luau yourself.
1. Build it with blocks
Add a part. Select it, open Script, choose Blocks, and build:
- When a player touches this
- Repeat 3 times, and inside it:
- Paint this (pick a colour)
- Wait 1 seconds
- Paint this (a different colour)
- Wait 1 seconds
- after the repeat: Show "Done!" on screen for 2 seconds
Play it. The part blinks three times when you touch it.
2. Flip to Luau
At the top of the block editor, switch to the Luau tab. That's the code your blocks made. Find:
- the line with
Touched:Connect(the when) for _ = 1, 3 do(the repeat)task.wait(1)(the wait)say("Done!", 2)(the show)- every
end. Each one closes something that was opened above it.
local busy1 = false
this.Touched:Connect(function(other)
if busy1 or not other:IsA("Player") then return end
busy1 = true
for _ = 1, 3 do
this.Color = Color3.fromHex("#ff6b6b")
task.wait(1)
this.Color = Color3.fromHex("#7fe6d6")
task.wait(1)
end
say("Done!", 2)
busy1 = false
end)
3. Edit the Luau
Copy the code. Add a real Script to the part (Add → Script), paste it in, and delete the block script. Now change things no block offers:
- Make it blink 10 times.
- Make the wait 0.2 seconds.
- Count the touches:
```luau
local touches = 0
-- inside the function, after busy1 = true:
touches += 1
say("Touched " .. touches .. " times", 2)
```
Done when
- Your Luau script runs with no red underline.
- You changed at least two numbers and added one line.
- You can point at a block and say which line it became.