Hello, how can I when a player clicks a button remove all the tools from their inventory/backpack? I'm using a script not local. Thanks.
COMMUNITY QUESTION
Remove all tools from player inventory?
5 answers
You have to put a LocalScript. Won't work otherwise
You'd have to get the player from either ClickDetetcor, PlayerAdded event, or Remote Function or Event. In this example, I use the PlayerAdded event.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player:WaitForChild("Backpack"):ClearAllChildren() -- Clears the tools.
end)
Also, this is a HELP site, not a REQUEST site. Please take a look at the rules/TOS before posting.
The script goes along like this: Seriously, don't post asking to make you a script. You gotta include code snippets as well.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
player:WaitForChild("Backpack"):ClearAllChildren()
end)
I want to clear backpack when player click a button not on join, how to do that?
Add a local script to the button you want players to click. This is what your local script should have.
function clearBackpack()
game.Players.LocalPlayer.Backpack:ClearAllChildren()
end
script.Parent.MouseButton1Click:Connect(clearBackpack)
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.
