I am trying to make a 'metal detector' that tests for if the player is at a certain XYZ and then clears their inventory. I have been using functions and if and then but it doesn't seem to work.
COMMUNITY QUESTION
How do I make a "metal detector"?
1 answer
It would be easier to do a "Player-Hit function" rather than the chosen method.
Find a part, insert a script and TouchInterest
In the Script, write
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
g=hit.Parent.Name
h=game.Players:findFirstChild(g).Backpack:getChildren()
for i=1, #h do
h[i]:remove()
end
end
end
script.Parent.Touched:connect(onTouched)
- Enjoy your anti-weapon door!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Oh, and the door can be any length. Make sure it is CanCollide = false and also anchored!