In my game, when a player steps onto a brick, the brick is supposed to fade away and once completely transparent, turn CanCollide to false. I tried this script, but it did not do anything when the player steps on the brick.
local trans = script.Parent.Transparency
function onTouch(hit)
while trans < 1 do
trans = 0.1
wait(0.1)
trans = trans + 0.1
if trans == 1 then
script.Parent.CanCollide = false
end
wait(3)
trans = 0
script.Parent.CanCollide = true
end
end
script.Parent.Touched:connect(onTouch)
Please help.

6 comments
Oh and before I forget, :connect is depreciated for some unknown reason, please use :Connect which does the same exact thing, as there's a possibility some time eventually :connect may do something different
If I remove the condition on line 08, would I have to remove the "end" on line 15 also?
The comment below is correct*
Or is the condition on line 08's end at line 10?
So I ran the code, and just in case I turned on Debug Errors "On All Exceptions". When I stepped on the brick, the game stopped and brought me to the script on line 03. The error read: "attempt to index upvalue 'part' (a number value)". If you would like I could show you the script I used, in case it contains an error.
:connect is depreciatedhypocrite; you made an entire forum thread about deprecation. Btw, it's deprecated, not depreciated.