Lesson 4
A fading platform
Goal: Make a platform disappear after it is stepped on, then return.
about 7 min3 practice exercises
A fading platform disappears shortly after a player steps on it, then comes back. It adds timing to a course without adding difficulty to the jumps.
local platform = script.Parent
local fading = false
platform.Touched:Connect(function(otherPart)
if fading then
return
end
if not otherPart.Parent:FindFirstChild("Humanoid") then
return
end
fading = true
for step = 1, 10 do
platform.Transparency = step / 10
task.wait(0.1)
end
platform.CanCollide = false
task.wait(3)
platform.Transparency = 0
platform.CanCollide = true
fading = false
end)
Three ideas are at work:
- A debounce.
fadingstops the many touches of one landing from starting the fade several times. - A loop for the fade. Ten steps of a tenth of a second each take transparency from 0.1 to 1, so the player sees it going.
- Two properties for "gone". Transparency only changes the look.
CanCollide = falseis what lets the player fall through.
Change the numbers to tune it: a shorter wait makes the fade faster and the platform harder.
Try it in Studio
Optional, and the best way to make it stick.
Put a fading platform over your lava. Tune the wait until it is tense but fair.
Go deeper on Rodex
Sources
Checked against Roblox's documentation on . The lesson is in our own words; these pages are the source of truth.