so i am making a game and i want to detect if something is equipped and delete it. but it just doesn’t work.
Script:
EquipItem.OnServerInvoke = function(player, itemName)
for i, v in pairs(player.Backpack:GetChildren()) do
for ii, vv in pairs(player.Character:GetChildren()) do
if v.Name == itemName and v:IsA("Tool") then
return "Equipped"
else
if vv and not vv.Name == "HumanoidRootPart" then
vv:Destroy()
wait(0.1)
v:Destroy()
wait()
local ToolCopy = player.Inventory[itemName]:Clone()
ToolCopy.Parent = player.Backpack
return "Equip"
else
v:Destroy()
wait()
local ToolCopy = player.Inventory[itemName]:Clone()
ToolCopy.Parent = player.Backpack
return "Equip"
end
end
end
end
end