script.Parent.Touched:connect(function() script.Parent:FindFirstChild("Humanoid") script.Parent.CanCollide = false if script.Parent:FindFirstChild("Humanoid") == false then script.Parent.CanCollide = true end end)
Supposed to turn the brick's CanCollide to false if a Humanoid is touching it, and when the player is not on/in the brick, cancollide goes back to true.
All this script does is turn the canCollide to false and it stops there.
You HAVE to check for the humanoid BEFORE ANYTHING ELSE.
script.Parent.Touched:connect(function() if script.Parent:FindFirstChild("Humanoid") then script.Parent.CanCollide = false elseif not script.Parent:FindFirstChild("Humanoid") then script.Parent.CanCollide = true end end)
you didnt check for it. you just sent an empty request. it finds it but doesnt know what to do with that info
EDIT: So it sent the empty request and moved on to setting it to false, then checking for the other condition. (Note: elseif is better practice)
REEDIT:
script.Parent.CanCollide = true script.Parent.Touched:connect(function(hit) -- oops forgot this important part if hit.Parent:FindFirstChild("Humanoid") then script.Parent.CanCollide = false end end) script.Parent.TouchEnded:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then script.Parent.CanCollide = true end end)