Uniform is not assigned to second team despite the first one being successfully assigned

Im making a game on roblox and i’ve written a simple script that makes your roblox character spawn with the designed shirts and pants, after putting in two teams and a GUI for choosing teams, the second team dont have their uniform assigned despite having them worn
after putting in two teams and a GUI for choosing teams, the second team doesnt have their uniform assigned.

ive tried rewriting the script and even trying new ones but to no avail, here are screenshots to back up my point

heres the code i used for the outfit giver

pnts = script.Pants
shirt = script.Shirt

function GiveClothes(character)
if not character:findFirstChild(“Shirt”) then
shirt:Clone().Parent = character
else character:findFirstChild(“Shirt”):Destroy()
shirt:Clone().Parent = character
end

if not character:findFirstChild("Pants") then 
	pnts:Clone().Parent = character
else character:findFirstChild("Pants"):Destroy()
	pnts:Clone().Parent = character
end

end

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(char)
wait(1.12)
local plr = game.Players:findFirstChild(char.Name)
print(char.Name)

	if plr.TeamColor ~= BrickColor.new("Cashmere") then 
		return
	else GiveClothes(char)
	end
end)

end)

1 Like

I wasn’t sure what your intentions were at first, but I may have figured it out and rewrote your script. I was unsure if you had multiple copies of this script that would give different sets of clothes to other teams, but the issue I see is you are only giving clothes to one specific team in your script.

--[[
	Place Pants and Shirts for each team in this script and add them to this table
	
	Example:
	
	["BrickColorName"] = {
		Shirt = script.MyTeamShirt;
		Pants = script.MyTeamPants
	},
	
	There should be a shirt name "MyTeamShirt" and "MyTeamPants" placed in the script and "BrickColorName" should be the name of the color you assign to 
	the team.
]]
local TeamClothes = {
	["Cashmere"] = {
		Shirt = script.Team1Pants;
		Pants = script.Team1Pants
	},
	["Forest green"] = {
		Shirt = script.Team2Pants;
		Pants = script.Team2Pants
	}
}

function GiveClothes(Character, TeamColorName)
	do
		local Shirt = Character:FindFirstChildOfClass("Shirt")
		local Pants = Character:FindFirstChildOfClass("Pants")
		
		if Shirt then
			Shirt:Destroy()
		end
		
		if Pants then
			Pants:Destroy()
		end
	end

	local ClothesSet = TeamClothes[TeamColorName]
	
	if not ClothesSet then
		warn("Could not find clothes for team: " .. TeamColorName)
		return
	end
	
	ClothesSet.Shirt:Clone().Parent = Character
	ClothesSet.Pants:Clone().Parent = Character
end

game.Players.PlayerAdded:connect(function(Player : Player)
	Player.CharacterAdded:connect(function(char)
		Player.CharacterAppearanceLoaded:Wait()
		GiveClothes(Player, Player.TeamColor.Name)
	end)
end)

This should fix your issue. Let me know if this helps!

1 Like