What Is Wrong With This? UPDATED PROBLEM, HELP IS NEEDED

Hey guys, I just made a team only clothing script, but why does it not work?
There are no errors or anything in output.
MY CODE

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)

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

Thanks! Help is appreciated.

1 Like

If it helps, this is my round system- it may be the reason it doesn’t work-

local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Maps = ServerStorage:WaitForChild('Maps'):GetChildren()
local Status = ReplicatedStorage:WaitForChild('Status')
while true do
  	
	
	--Intermission
	
	local Countdown = 20 -- intermission, make this as long as you want
	
	repeat wait(1)
		Countdown = Countdown - 1
		
		Status.Value = 'Intermission : '..Countdown
	until Countdown <= 0
	
	--Choose the map.
	
	Status.Value = 'Choosing Map...'
	
	local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
    wait(0.5)
	local VSpawns = ChosenMap:FindFirstChild('VikingSpawns'):GetChildren() --You need to create this in your map
	local SSpawns = ChosenMap:FindFirstChild('SamuraiSpawns'):GetChildren() --You need to create this in your map
	local KSpawns = ChosenMap:FindFirstChild('KnightSpawns'):GetChildren() --You need to create this in your map

	wait(3) -- little pause, make this as long as you want
	
	ChosenMap.Parent = workspace
	Status.Value = 'Map chosen, teleporting players.'
	
	wait(2) -- little pause, make this as long as you want

	--teleport the players
	
	local playersInRound = {} -- track alive players
	local teams = {
		[1] = {}, -- Samurai
		[2] = {}, -- Vikings
		[3] = {} -- Knights
	}
	local iterator = math.random(1,3) -- Randomly choose the first team to fill
	local samuraiTeam = game:GetService("Teams"):FindFirstChild("Samurai") --Make sure this points to the correct team
	local vikingsTeam = game:GetService("Teams"):FindFirstChild("Vikings") --Make sure this points to the correct team
	local knightsTeam = game:GetService("Teams"):FindFirstChild("Knights") --Make sure this points to the correct team
	local neutralTeam = game:GetService("Teams"):FindFirstChild("Neutral") --Make sure this points to the correct team
	
	local connections = {} -- store connections to disconnect later
	for _, Player in pairs(Players:GetChildren()) do
		if Player.Character and Player.Character:FindFirstChild('Humanoid') then
			local team = nil
			table.insert(playersInRound, Player) -- add all players to table
			
			--Fill the teams
			if iterator > 3 then
				iterator = 1
			end
			
			if iterator == 1 then
				table.insert(teams[iterator], Player)
				local RandomSpawn = SSpawns[math.random(1, #SSpawns)]
				Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
				Player.Team = samuraiTeam
			elseif iterator == 2 then
				table.insert(teams[iterator], Player)
				local RandomSpawn = VSpawns[math.random(1, #VSpawns)]
				Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
				Player.Team = vikingsTeam
			else
				table.insert(teams[iterator], Player)
				local RandomSpawn = KSpawns[math.random(1, #KSpawns)]
				Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
				Player.Team = knightsTeam
			end
			
			connections[Player.Name] = Player.Character.Humanoid.Died:Connect(function()
				table.remove(playersInRound, table.find(playersInRound, Player))
				
				--Find which team and remove the player from the team
				for i=1, 3 do
					if table.find(teams[i], Player) then
						table.remove(teams[i], table.find(teams[i], Player))
					end
				end
			end)
			
			iterator += 1
		end
	end
	
	connections["Removing"] = game.Players.PlayerRemoving:Connect(function(player) -- remove player from list if they leave
		local ind = table.find(playersInRound, player)
		if ind then
			table.remove(playersInRound, ind)
			--Find which team and remove the player from the team
			for i=1, 3 do
				if table.find(teams[i], player) then
					table.remove(teams[i], table.find(teams[i], player))
				end
			end
		end
	end)
	
	Countdown = 5 -- Starting Round In, make this as long as you want
	
	repeat wait(1)
		Countdown = Countdown - 1
		
		Status.Value = 'Starting Round in : '..Countdown
	until Countdown <= 0
	
	Countdown = 60 -- Game Time
	
	repeat wait(1)
		Countdown = Countdown - 1
		
		Status.Value = 'Ingame : '..Countdown
	until Countdown <= 0 or #playersInRound == 0 or (#teams[1] == 0 and #teams[2] == 0) or (#teams[1] == 0 and #teams[3] == 0) or (#teams[2] == 0 and #teams[3] == 0) 

    -- Determine winner and give reward
    if (#teams[2] == 0 and #teams[3] == 0) and #teams[1] > 0 then -- Samurai won
		    local success, message = pcall(function()
	        Status.Value = "Samurai won the game!"
            wait(3)
			local playerList = Players:GetChildren()
			for i=1, #playerList do
				local player = playerList[i]
				if player.Team == samuraiTeam then
		            print("The Winner is: " .. player.Name)
		            player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
					player.leaderstats.Denarius.Value = player.leaderstats.Denarius.Value + 100
					player.Team = neutralTeam
				end
			end
        end)
        if not success then
            warn("An error occurred while rewarding winner: " .. message)
        end
    elseif (#teams[1] == 0 and #teams[3] == 0) and #teams[2] > 0 then -- Vikings won
		    local success, message = pcall(function()
			        Status.Value = "Vikings won the game!"
                    wait(3)
			local playerList = Players:GetChildren()
			for i=1, #playerList do
				local player = playerList[i]
				if player.Team == vikingsTeam then
		            print("The Winner is: " .. player.Name)
		            player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
					player.leaderstats.Denarius.Value = player.leaderstats.Denarius.Value + 100
					player.Team = neutralTeam
				end
			end
        end)
        if not success then
            warn("An error occurred while rewarding winner: " .. message)
        end
    elseif (#teams[1] == 0 and #teams[2] == 0) and #teams[3] > 0 then -- Knights won
		    local success, message = pcall(function()
	        Status.Value = "Knights won the game!"
            wait(3)
			local playerList = Players:GetChildren()
			for i=1, #playerList do
				local player = playerList[i]
				if player.Team == knightsTeam then
		            print("The Winner is: " .. player.Name)
		            player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
					player.leaderstats.Denarius.Value = player.leaderstats.Denarius.Value + 100
					player.Team = neutralTeam
				end
			end
        end)
        if not success then
            warn("An error occurred while rewarding winner: " .. message)
        end
    else
        print("There was no winner.")
        Status.Value = "There was a stalemate this round"
        wait(3)
    end

	--Kill the players
	for _, connection in pairs(connections) do -- disconnect connections to prevent memory leaks
		connection:Disconnect()
	end
	
	
for _, Player in pairs(Players:GetPlayers()) do
		Player.Team = neutralTeam
		Player:LoadCharacter()
	end
	
	ChosenMap:Destroy()
	
	Status.Value = 'Round Ended, waiting for new game.'

	
	wait(4) -- little pause, make this as long as you want.
	
end
1 Like

p is already the player though… no need to add “local plr = game.Players:findFirstChild(char.Name)”

1 Like

Will that make it work? 30 charsacters

2 Likes

@ScriptLocalize will that make it work? Also does anyone else know why it doesn’t work?

i think thats it… if it doesnt work show if it has error.

1 Like

Still doesn’t work sadly… No error either…
How would I edit my round system to make it so it gives clothes? @ScriptLocalize

Doesn;'t work still sadly…

I’ve edited the round system to try and make it work, heres the bits that handle the clothes giving, but it still fails to work.

local iterator = math.random(1,3) -- Randomly choose the first team to fill
	local samuraiTeam = game:GetService("Teams"):FindFirstChild("Samurai") --Make sure this points to the correct team
	local vikingsTeam = game:GetService("Teams"):FindFirstChild("Vikings") --Make sure this points to the correct team
	local knightsTeam = game:GetService("Teams"):FindFirstChild("Knights") --Make sure this points to the correct team
	local neutralTeam = game:GetService("Teams"):FindFirstChild("Neutral") --Make sure this points to the correct team
	
	local connections = {} -- store connections to disconnect later
	for _, Player in pairs(Players:GetChildren()) do
		if Player.Character and Player.Character:FindFirstChild('Humanoid') then
			local team = nil
			table.insert(playersInRound, Player) -- add all players to table
			
			--Fill the teams
			if iterator > 3 then
				iterator = 1
			end
			
			if iterator == 1 then
				table.insert(teams[iterator], Player)
				local RandomSpawn = SSpawns[math.random(1, #SSpawns)]
				Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
				Player.Team = samuraiTeam
local newKatana = Katana:Clone()
			newKatana.Parent = Player.Backpack
local Pants = game.Workspace:WaitForChild("PantsSamurai")
local Shirt = game.Workspace:WaitForChild("ShirtSamurai")

function GiveClothes(Character)
	if not Character:FindFirstChildOfClass("Shirt") then 
		Shirt:Clone().Parent = Character
	else 
		Character:FindFirstChildOfClass("Shirt"):Destroy()
		Shirt:Clone().Parent = Character
	end

	if not Character:FindFirstChildOfClass("Pants") then 
		Pants:Clone().Parent = Character
	else 
		Character:FindFirstChildOfClass("Pants"):Destroy()
		Pants:Clone().Parent = Character
	end
end
	

			elseif iterator == 2 then
				table.insert(teams[iterator], Player)
				local RandomSpawn = VSpawns[math.random(1, #VSpawns)]
				Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
				Player.Team = vikingsTeam
local newBattleAxe = BattleAxe:Clone()
			newBattleAxe.Parent = Player.Backpack
local Pants = game.Workspace:WaitForChild("PantsVikings")
local Shirt = game.Workspace:WaitForChild("ShirtVikings")

function GiveClothes(Character)
	if not Character:FindFirstChildOfClass("Shirt") then 
		Shirt:Clone().Parent = Character
	else 
		Character:FindFirstChildOfClass("Shirt"):Destroy()
		Shirt:Clone().Parent = Character
	end

	if not Character:FindFirstChildOfClass("Pants") then 
		Pants:Clone().Parent = Character
	else 
		Character:FindFirstChildOfClass("Pants"):Destroy()
		Pants:Clone().Parent = Character
	end
end
			else
				table.insert(teams[iterator], Player)
				local RandomSpawn = KSpawns[math.random(1, #KSpawns)]
				Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
				Player.Team = knightsTeam
local newSword = Sword:Clone()
			newSword.Parent = Player.Backpack
local Pants = game.Workspace:WaitForChild("PantsKnights")
local Shirt = game.Workspace:WaitForChild("ShirtKnights")

function GiveClothes(Character)
	if not Character:FindFirstChildOfClass("Shirt") then 
		Shirt:Clone().Parent = Character
	else 
		Character:FindFirstChildOfClass("Shirt"):Destroy()
		Shirt:Clone().Parent = Character
	end

	if not Character:FindFirstChildOfClass("Pants") then 
		Pants:Clone().Parent = Character
	else 
		Character:FindFirstChildOfClass("Pants"):Destroy()
		Pants:Clone().Parent = Character
	end
end
			end
			
			connections[Player.Name] = Player.Character.Humanoid.Died:Connect(function()
				table.remove(playersInRound, table.find(playersInRound, Player))
				
				--Find which team and remove the player from the team
				for i=1, 3 do
					if table.find(teams[i], Player) then
						table.remove(teams[i], table.find(teams[i], Player))
					end
				end
			end)
			
			iterator += 1
		end
	end
2 Likes

Bumping this up again in hope for some help. Thanks.

1 Like

I will try in the morning, if it works I’ll put as solution!

1 Like

Try this, it worked for me:

local pnts = script.Pants
local shirt = script.Shirt

local function GiveClothes(character)
	local humanoid = character:WaitForChild("Humanoid")
	
	local description = humanoid:GetAppliedDescription()
	
	description.Shirt = shirt.ShirtTemplate
	description.Pants = pnts.PantsTemplate
	
	humanoid:ApplyDescription(description)
	description:Destroy()
end

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAppearanceLoaded:Connect(function(char)
		if (not char.Parent) then
			char.AncestryChanged:Wait()
		end
		if (p.TeamColor ~= BrickColor.new("Really red")) then
			return
		end
		GiveClothes(char)
	end)
end)
1 Like