What do you want to achieve? I would like to achieve, when pressing a button GUI you equip a shirt and pants, and if the user wants to unequip them, they should press again the same button and it will automatically unequip them, and so on.
What is the issue? I can’t make it work, I tried so far and I only achieved to equip the clothes but not to unequip them or equip them back again all the times the user wants.
What solutions have you tried so far? I looked for youtube tutorials and on roblox devforum but I haven’t found anything that could be useful for the GUI I’m trying to do.
I tried that
local button = script.Parent.GiveUniform
local debounce = true
local UniEventGC = game.ReplicatedStorage:WaitForChild("UniformGiveEvent")
button.MouseButton1Click:Connect(function()
if debounce then
debounce = false
UniEvent:FireServer()
end
end)
local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEvent"
local Shirt = "rbxassetid://0"
local Pants = "rbxassetid://0"
function GiveUni(plr)
local character = plr.Character
local shirt = character.Shirt
local pants = character.Pants
shirt.ShirtTemplate = Shirt
pants.PantsTemplate = Pants
end
Event.OnServerEvent:Connect(GiveUni)
I know that the shirt and pants ID are 0 I made that on purpose.
That’s what I tried so far but doesn’t work, only works one time and that is, and if you press again the uniform doesn’t unequip.
If anyone is willing to help me, I would really appreciate it.
Just check if the player already has uniform on the server before giving it to them, and if they do, remove it, but if they don’t, then equip it.
function GiveUni(plr)
if plr.Character.Shirt.ShirtTemplate == Shirt then
plr.Character.Shirt.ShirtTemplate = original shirt
plr.Character.Pants.PantsTemplate = original pants
return
end
local character = plr.Character
local shirt = character.Shirt
local pants = character.Pants
shirt.ShirtTemplate = Shirt
pants.PantsTemplate = Pants
end
There should be character’s original shirt and pants. You can get them using game.Players:GetHumanoidDescriptionFromUserId(plr.UserId).Shirt
and game.Players:GetHumanoidDescriptionFromUserId(plr.UserId).Pants
Just paste this instead of your own function, it should work perfectly fine:
function GiveUni(plr)
if plr.Character.Shirt.ShirtTemplate == Shirt then
plr.Character:WaitForChild("Humanoid"):ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(plr.UserId))
return
end
local character = plr.Character
local shirt = character.Shirt
local pants = character.Pants
shirt.ShirtTemplate = Shirt
pants.PantsTemplate = Pants
end
Ok, I used the script you sent and it worked, but the problem is that it don’t give the clothes I had, just removes all the clothes, how I can fix that?