Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this wall script not working?

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)

1 answer

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.

5 comments

0

Actually, it still isn't working. The brick is not going Dis-collideable.

0

The problem might be that the projectile is moving too fast.

0

well, it works once, then when the wall Can Collide it doesn't let my projectile pass through again.

0

There is a wait(3) in there. Are you waiting for at least 3 seconds?

0

it doesn't let my projectile pass ever again.

This discussion is preserved as it was. New answers, comments, and votes are closed.