Basically how do I delete items in a player’s backpack through a server script.
I tried doing this, but it doesn’t work and there are no errors
local items = player.Backpack:FindFirstChildOfClass("Tool")
player.items:Destroy()
Basically how do I delete items in a player’s backpack through a server script.
I tried doing this, but it doesn’t work and there are no errors
local items = player.Backpack:FindFirstChildOfClass("Tool")
player.items:Destroy()
I think that’s removing a players items through a local script
It should still nonetheless tell you how to delete items from a player’s backpack.
Tools that are unequipped will be in the Backpack, and tools that are equipped will be within the character. If you want to delete a certain tool from the player (in the backpack and character), you could try doing this:
local itemName = "Cup" --Change this
if player.Backpack:FindFirstChild(itemName) and player.Backpack[itemName]:IsA("Tool") then
player.Backpack.Cup:Destroy()
end --Destroy Non-Equipped tool in inventory / Backpack
if player.Character and player.Character:FindFirstChild(itemName) and player.Character[itemName]:IsA("Tool") then
player.Character[itemName]:Destroy()
end --Destroy Equipped Tool
If you want to remove ALL tools in a backpack, you can do
for _, tool in ipairs(player.Backpack:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end --Deletes all tools from Backpack
if player.Character:FindFirstChildOfClass("Tool") then
player.Character:FindFirstChildOfClass("Tool"):Destroy()
end --Deletes Equipped Tool
What do we reference player as since its a server script?
Can you post your script so we can better help you?
What is the player referenced as?
local player = game:GetService(“Players”).LocalPlayer
Hello everyone, sorry for reviving the topic but I’m actually trying to use it myself but it keeps giving me this error and I can’t seem to find a solution to it
do you know when you have the same tool like 5 item and when it destory it all gone how to make it only destory once