Hey, I’m making a GUI where you can click a button to equip an accessory to your character.
Everything works perfectly, except that I want a way to remove an accessory if the player clicks the button again after they put it on.
How can this be done?
This is my code:
Client side
local CapeEvent = game:GetService("ReplicatedStorage").EquipAccessoryCape
script.Parent.MouseButton1Down:Connect(function()
CapeEvent:FireServer("EquipAccessoryCape", game:WaitForChild("Lighting").Accessories.Cape)
end)
Server side:
local RemoteEvent = game.ReplicatedStorage:WaitForChild("EquipAccessoryCape")
local hascape = false
RemoteEvent.OnServerEvent:Connect(function(player, topic, info)
if topic == "EquipAccessoryCape" and hascape == false then
local newAccessory = info:Clone()
newAccessory.Parent = player.Character
hascape = true
end
end)
Any help is appreciated.