I am building an obby, and one of the stages is where there are multiple platforms, that when touched by the player, fade away and disappear (Transparency = 1 and canCollide = false). However, when the player touches the platform, after fading away, the player can still stand and walk on the platform for multiple seconds. Also, I am new to scripting, so I am sorry if this is a very obvious problem. Here is the code that I used:
local p = script.Parent function onTouch(part) for i=1,100 do p.Transparency = p.Transparency + 0.01 wait(0.01) end p.CanCollide = false wait(2.5) p.Transparency= 0 p.CanCollide = true end p.Touched:connect(onTouch)
First, fyi, you don't need the argument "part" in line 3 --Or at least I don't think you don't...
Second, I am not sure how to fix your CanColide method (It is the first thing to try in my opinion though) But, when things don't work, I like to improvise! Try reparenting the part to server/replicated storage, changing the transparency, and then reparenting to workspace.
local p = script.Parent function onTouch(part) for i=1,100 do p.Transparency = p.Transparency + 0.01 wait(0.01) end p.parent = game.ReplicatedStorage wait(2.5) p.Transparency= 0 p.parent = workspace end p.Touched:connect(onTouch)
Rewrite the code a bit like this
local p = script.Parent p.Transparency = p.Transparency + 0.01 function onTouch() p.Transparency= 0 p.CanCollide = false wait(2.5) p.Transparency = p.Transparency + 0.01 p.CanCollide = true end p.Touched:connect(onTouch)
Quick question. Why do you need this part?
for i=1,100 do p.Transparency = p.Transparency + 0.01 wait(0.01) end