It's supposed to make a weapon's projectile go through the brick, but it isn't working.
function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid == nil) then -- if there is no humanoid in the thing that's touching it... script.Parent.CanCollide = false -- make the brick passable, or go-through (not working) wait(3) --wait 3 seconds script.Parent.CanCollide = true -- make the brick into a full brick again (not working) elseif -- or if (humanoid ~= nil) then -- a humanoid exists, then humanoid.Health = 0 -- kill the player end end script.Parent.Touched:connect(onTouch)
Try this instead (explanation below):
function onTouch(part) if part.Parent:findFirstChild("Humanoid") ~= nil then humanoid = part.Parent:findFirstChild("Humanoid") humanoid.Health = 0 else script.Parent.CanCollide = false wait(3) script.Parent.CanCollide = true end end script.Parent.Touched:connect(onTouch)
The problem I found was that you were defining a variable for something that you did not know existed within that Model, so I rewrote the script a bit.