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

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

Asked by 8 years ago

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)

0
edited my answer koolkid8099 705 — 8y

2 answers

Log in to vote
-2
Answered by 8 years ago
--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!

Ad
Log in to vote
0
Answered by 8 years ago

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

0
what about the player who clicks the button? not all players TheTermaninator 45 — 8y
0
edited koolkid8099 705 — 8y
0
k TheTermaninator 45 — 8y
0
Do I put this script on startergear? Rdumb1 4 — 5y

Answer this question