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

Need assistance on click to remove tools?

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)

2 comments

0

Please use code blocks for scripts.It is in edit mode at the top left corner with a lua logo.

1

Nice free model

1 answer

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

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