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.
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!
Closed as Not Constructive by youtubemasterWOW, JakyeRU, and Shawnyg
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?