Skinstashery
Roblox
Home / Roblox / Studio script library / Disappearing platform
RB-004

Roblox disappearing platform script

A platform that fades away after someone steps on it, then comes back.

Script type
Script
Where it goes
Inside the Part
Category
World and effects

For your own game in Roblox Studio. Not for use in other people's games.

The code

-- Disappearing platform: touched -> short delay -> gone -> comes back.

local DELAY_BEFORE_FALL = 1     -- seconds after the touch before it vanishes
local TIME_GONE = 3             -- seconds it stays invisible
local FADE_TIME = 0.4           -- seconds the fade takes

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local platform = script.Parent
local active = false

platform.Touched:Connect(function(hit)
	if active then
		return
	end
	if not Players:GetPlayerFromCharacter(hit.Parent) then
		return
	end

	active = true

	task.wait(DELAY_BEFORE_FALL)

	local fadeOut = TweenService:Create(platform, TweenInfo.new(FADE_TIME), { Transparency = 1 })
	fadeOut:Play()
	fadeOut.Completed:Wait()
	platform.CanCollide = false

	task.wait(TIME_GONE)

	platform.CanCollide = true
	local fadeIn = TweenService:Create(platform, TweenInfo.new(FADE_TIME), { Transparency = 0 })
	fadeIn:Play()
	fadeIn.Completed:Wait()

	active = false
end)

How to set it up

  1. Insert a Part and set Anchored to true.
  2. Add a Script inside the Part and paste the code.
  3. Copy and paste the whole part to make a row of platforms. Each copy keeps its own script.
  4. Play and walk across them.

Change it

More in World and effects

All Roblox scripts

More Roblox tools