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

What are ways I can remove a tool from a players backpack?

Post Comment ways plz

this is for a gui button btw

	local ded = find:Destroy()
	ded.Parent = player.Backpack

does not work for the script im trying to use this error keeps poppin up

18:25:14.303 - Players.Player.PlayerGui.Shop/System.InventoryTab.Inventory.Item.EquipOrUnequip.LocalScript:10: attempt to index local 'cl' (a nil value)

1 comment

0

edited my answer

2 answers

✓ Accepted answer
--LocalScript in StarterPack or StarterGui

local player = game:GetService("Players").LocalPlayer

player.Backpack.ITEMNAMEHERE:remove()

You could also restrict permission too!

--LocalScript in StarterPack or StarterGui

local player = game:GetService("Players").LocalPlayer

if player.Name == "USERNAMEHERE" then

else

player.Backpack.ITEMNAMEHERE:remove()

end

local toolholders = {"Player", "USERNAMEHERE"}

for i, v in pairs(toolholders) do

if v == player.Name then

end
else
player.Backpack.ITEMNAMEHERE:remove()
end

Hope this helped!

To remove certain tools from playeys, you could use a local script

player = game.Players.LocalPlayer

player.Backpack:FindFirstChild("NAME HERE"):Destroy()

you can fire this script with a event as your please. You could also use a script that removes it when a part is touched. For example, here is a script that is inside of the part

script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local pack = player.Backpack
pack:FindFirstChild("NAME HERE"):Destroy()

you can also do it by click detector 2. Click detector uses a paramter of the player who clicked it so therefor you would do the following

script.Parent.ClickDetector.MouseClick:connect(function(player)
local pack = player.Backpack
pack:FindFirstChild("NAME HERE"):Destroy()
end)

Of course there are several other ways to do it, but these two are the most common

4 comments

0

what about the player who clicks the button? not all players

0

edited

0

k

0

Do I put this script on startergear?

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