Below is a script that lowers a rock into lava, so you die if you stand on it too long, but if you stand on it without jumping off of it, it reacts weird because it sort of resets the script when you touch it again. I am looking for a way to make the touched function not to do anything with the input while the script is running. Thanks in advance for any help!
function touch(hit)
if hit.Parent ~= nil then
local player = game.Players:playerFromCharacter(hit.Parent)
if player ~= nil then
script.Parent.Parent.first.Transparency = 1
script.Parent.Parent.first.CanCollide = false
script.Parent.Parent.second.Transparency = 0
wait(0.1)
script.Parent.Parent.second.Transparency = 1
script.Parent.Parent.second.CanCollide = false
script.Parent.Parent.third.Transparency = 0
wait(0.1)
script.Parent.Parent.third.Transparency = 1
script.Parent.Parent.third.CanCollide = false
script.Parent.Parent.fourth.Transparency = 0
wait(0.1)
script.Parent.Parent.fourth.Transparency = 1
script.Parent.Parent.fourth.CanCollide = false
script.Parent.Parent.fifth.Transparency = 0
wait(0.1)
script.Parent.Parent.fifth.Transparency = 1
script.Parent.Parent.fifth.CanCollide = false
script.Parent.Parent.sixth.Transparency = 0
wait(0.1)
script.Parent.Parent.sixth.Transparency = 1
script.Parent.Parent.sixth.CanCollide = false
wait(1) --RESET ROCK--
script.Parent.Parent.first.Transparency = 0
script.Parent.Parent.first.CanCollide = true
script.Parent.Parent.second.CanCollide = true
script.Parent.Parent.third.CanCollide = true
script.Parent.Parent.fourth.CanCollide = true
script.Parent.Parent.fifth.CanCollide = true
script.Parent.Parent.sixth.CanCollide = true
end end end
script.Parent.Touched:connect(touch)

1 comment
I fixed my code