I'm trying to make this object not collide-able after it has disappeared, but it stays collidable.
local touchedpart = script.Parent function onTouch(part) while true do wait(0.3) local tptrans = touchedpart.Transparency touchedpart.Transparency = tptrans + 0.12 end end touchedpart.Touched:connect(onTouch) if touchedpart.Transparency == 1 then touchedpart.CanCollide = false end
The problem is the value is going above when, while your script is checking if it EQUALS one. Here's a fixed version of your code:
local touchedpart = script.Parent function onTouch(part) while true do wait(0.3) local tptrans = touchedpart.Transparency touchedpart.Transparency = tptrans + 0.12 end end touchedpart.Touched:connect(onTouch) if touchedpart.Transparency >= 1 then touchedpart.CanCollide = false end
It also should noted that you're only checking once for the Transparency. Here's another version of your code that should work better:
function onTouch(part) while true do wait(0.3) local tptrans = touchedpart.Transparency touchedpart.Transparency = tptrans + 0.12 if touchedpart.Transparency >= 1 then touchedpart.CanCollide = false end end end touchedpart.Touched:connect(onTouch)