Advertisement
irishWarlock89

Disappearing Platform Script

Jun 22nd, 2023 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | Source Code | 0 0
  1. --Parent: a platform part
  2. --Trigger: when the platform is stepped on or touched
  3. --Result: after a delay, the platform will begin to disappear
  4.  
  5. local initialDelay = 1 --how long it takes before the platform starts to disappear
  6. local disappearingSpeed = 1 --how fast it takes for the platform to disappear
  7. local respawnDelay = 2 --how long it takes for the platform to reappear after disappearing
  8.  
  9. local platform = script.Parent --reference to the platform part
  10.  
  11. local isTouched = false --if the platform has been touched or not, debounce
  12.  
  13. local function platformTouched()
  14.     if isTouched then
  15.         return
  16.     end
  17.     isTouched = true
  18.     task.wait(initialDelay)
  19.     for i=1,10,1 do
  20.         platform.Transparency += 0.1
  21.         task.wait(disappearingSpeed/10)
  22.     end
  23.     platform.CanCollide = false
  24.     task.wait(respawnDelay)
  25.     platform.CanCollide = true
  26.     platform.Transparency = 0
  27.     isTouched = false
  28. end
  29.  
  30. platform.Touched:Connect(platformTouched)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement