I was trying to make items obtained through like shops to be removed after death by putting server script inside my tools
(heres the shop script i used)
local price = 100
script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
local clone = game.ReplicatedStorage:WaitForChild("M16"):Clone()
if plr.leaderstats.Coin.Value >= price then
plr.leaderstats.Coin.Value = plr.leaderstats.Coin.Value - price
clone.Parent = plr.Backpack
clone:Clone().Parent = plr.StarterGear
end
end)
example)
but i couldnt get rid of items obtained through shop by putting
local Tool = script.Parent
Char = Tool.Parent.Parent.Character
function onDeath()
Tool:Destroy()
end
Char.Humanoid.Died:connect(onDeath)
so i tried like
for i, v in pairs(Player.StarterGear:GetChildren()) do
if v.Name == DestroyItem.Name then
v:Destroy()
end
end
for i, v in pairs(Player.Backpack:GetChildren()) do
if v.Name == DestroyItem.Name then
v:Destroy()
end
end
for i, v in pairs(Player.Character:GetChildren()) do
if v.Name == DestroyItem.Name then
v:Destroy()
end
end
but it didnt worked either.
im so frustrated and i dont know what to try next.