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

Need assistance on click to remove tools?

Asked by 5 years ago

I need to have a trash can, that when you click it, it removes your tools from your inventory. This is what I have so far. Can anyone assist?

function onClicked() local human = onClicked.Parent:findFirstChild("Humanoid") if (human ~= nil) then onClicked().Parent.Name h = game.Players:findFirstChild(g).Backpack:getChildren() for i=1, #h do h[i]:remove() end end end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

0
Please use code blocks for scripts.It is in edit mode at the top left corner with a lua logo. rochel89 42 — 5y
1
Nice free model User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Put this script in the Model

script.Parent.MouseClick:Connect(function(plr)
    for _, tool in pairs(plr.Backpack:GetChildren()) do
        tool:Destroy()
    end
end)

This should fix it.

Best of luck developer

Ad

Answer this question