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

Remove all tools from player inventory? [closed]

Asked by 4 years ago

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.

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?

5 answers

Log in to vote
0
Answered by
qVoided 221 Moderation Voter
4 years ago

You have to put a LocalScript. Won't work otherwise

Ad
Log in to vote
0
Answered by 4 years ago

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.

Log in to vote
0
Answered by 4 years ago

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)
Log in to vote
0
Answered by 4 years ago

I want to clear backpack when player click a button not on join, how to do that?

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!