Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a "metal detector"?

Asked by 8 years ago

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.

1 answer

Log in to vote
0
Answered by 8 years ago

It would be easier to do a "Player-Hit function" rather than the chosen method.

1) Find a part, insert a script and TouchInterest

2) 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)

3) Enjoy your anti-weapon door!

0
Oh, and the door can be any length. Make sure it is CanCollide = false and also anchored! TheHospitalDev 1134 — 8y
Ad

Answer this question