Removing Accessories

game.ReplicatedStorage.InventoryEvents.EquipTenKillsPrize.OnServerEvent:Connect(function(Player)

game.ReplicatedStorage.InventoryItems.Pot:Clone().Parent = Player.Character

Player.Inventory.TenKillsPrize.Value = 1

Player.Inventory.ThirtyKillsPrize.Value = 0

Player.Inventory.FiftyKillsPrize.Value = 0

Player.Character:FindFirstChild("StudVR"):Destroy()

Player.Character:FindFirstChild("FlamingHorns"):Destroy()

end)

game.ReplicatedStorage.InventoryEvents.EquipThirtyKillsPrize.OnServerEvent:Connect(function(Player)

game.ReplicatedStorage.InventoryItems.StudVR:Clone().Parent = Player.Character

Player.Inventory.ThirtyKillsPrize.Value = 1

Player.Inventory.TenKillsPrize.Value = 0

Player.Inventory.FiftyKillsPrize.Value = 0

Player.Character:FindFirstChild("Pot"):Destroy()

Player.Character:FindFirstChild("FlamingHorns"):Destroy()

end)

game.ReplicatedStorage.InventoryEvents.EquipFiftyKillsPrize.OnServerEvent:Connect(function(Player)

game.ReplicatedStorage.InventoryItems.FlamingHorns:Clone().Parent = Player.Character

Player.Inventory.ThirtyKillsPrize.Value = 0

Player.Inventory.TenKillsPrize.Value = 0

Player.Inventory.FiftyKillsPrize.Value = 1

Player.Character:FindFirstChild("Pot"):Destroy()

Player.Character:FindFirstChild("StudVR"):Destroy()

end)

How do I fix this?

Check if the Items Equipped Exist, if so then Remove them and add the Accessory, you may be able to add a Atrribute as a form of Tag, or use CollectionService, and use a for loop to delete the item that has it.

Instead of using Multiple RemoteEvents, Use one:

EquipPrize.OnServerEvent:Connect(function(Player, Item, Req, Val, Val1, Val2)
if Player.Kills >= Req then
for _,i in pairs(Player.Character:GetChildren()) do
  if i:IsA("Accessory") and i:GetAttribute("Tag") then
    i:Destroy()
    Val.Value = 1
    Val1.Value = 0
    Val2.Value = 0
    
  end
end
Item:Clone().Parent = Player.Character
else
return
end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.