I'm trying to make a certain brick to pass through a wall. I want to let a certain brick called "x" to pass through the wall "y". If the wall detects another brick, whose name is not "x", then it will delete it.
function lala() if game.Workspace.Name.x -- I have no idea what to do around here then print("x confirmed") else local part = game.Workspace.Part -- This one too part:Destroy() print("Removing this junk.") end end script.Parent.Parent.y.Touched:connect(lala)
Now, the problem is that the wall will immediately execute the Else code, whenever the "x" block passes through. It will delete ANY random brick that has the name "Part".
So my questions are:
Your conditional statements are incorrectly formatted.
To check a name and compare it to your criteria, an equation is in order.
if part.Name == x then end
In this case, part is not defined. Luckily, however, you can extract this information through your touched event.
x = "Passable Part" -- Or part hierarchy (game.Workspace["Passable Part"]) y = game.Workspace.Door -- Or a script hierarchy (script.Parent) function touched(part) if part.Name == x or part == x then print("Part passed! I suggest toggling the door's CanCollide for effect.") else print("Part is not x.") end end y.Touched:connect(touched)
Do what Drako did, then maybe instead of printing a message in output, try first renaming the part to "deleteme". Then add game.Workspace.deleteme:Destroy()
Just a guess...