Hi,
im trying to make a script which allows people to equip and unequip items in their GUI inventory.
I have made it so they can equip and unequip ( This works!) but when they go to equip again it doesnt go back to its original function.
equip.MouseButton1Click:Connect(function(equipped)
clicks += 1
equip.Text = "Equipped"
local character = player.Character
task.wait()
local Head = character:FindFirstChild('Head') -- will wait until the head is loaded, at that time the code below will be yielded by this function, using waitforchild on something that doesnt exist will yield infinitely
local Torso = character:FindFirstChild('Torso')
local LowerTorso = character:FindFirstChild('LowerTorso') -- both has waistbackattachment
local plrTrail = Trail:Clone()
if Torso then
plrTrail.Parent = Torso
plrTrail.Attachment1 = Torso.WaistBackAttachment
elseif LowerTorso then
plrTrail.Parent = LowerTorso
plrTrail.Attachment1 = LowerTorso.WaistBackAttachment
end
plrTrail.Attachment0 = Head.FaceFrontAttachment
if clicks == 2 then
clicks = 0
equip.Text = "Equip"
plrTrail:Destroy()
plrTrail.Attachment0:Destroy()
plrTrail.Attachment1:Destroy()
end
end)
end
end
Heres the code im using for the equip and unequipping of the items. Preferably id like it s that when they go to equip for the second time it replays the proginal function ‘equipped’.
Thankyou