I am trying to make the tool in a user's hand delete from the character and also from starter gear. However, it only deletes from the character and not from starter gear. Below is inside a local script under an image button. Why is this happening?
local function onCreatePartFired(player, tool)
local SG = player.StarterGear
if tool then
tool:Destroy()
end
if SG:FindFirstChild(tool.Name) then
print("hey")
SG[tool.Name]:Destroy()
end
end
local Players = game:GetService("Players")
plr = game:GetService("Players").LocalPlayer
char = plr.Character or plr.CharacterAdded:Wait()
script.Parent.MouseButton1Click:Connect(function()
local tool = char:FindFirstChildOfClass("Tool")
onCreatePartFired(plr,tool)
end)

2 comments
Hello! Thank you, it's working! But, for some reason when I respawn, the item comes back to backpack even though I deleted it from starter gear and the character. Is there any reason for that?
This sounds like it's because you're deleting the tool from the current instance of the player, and when the player respawns the tool exists wherever it's loading the new character from. Similar to how when you start a game, anything in StarterGui moves to PlayerGui, and if you delete something from the StarterGui in game, the player's GUI will not be updated. Does that make sense?