Auto uniforms giver not working after respawn

------------- UNIFORMS

local uniforms = game.ReplicatedStorage.Uniforms
local NCASHR = uniforms.NCA.NCALR.Shirt.ShirtTemplate
local NCAPHR = uniforms.NCA.NCALR.Pants.PantsTemplate
local NCAPLR = uniforms.NCA.NCALR.Pants.PantsTemplate
local NCASLR = uniforms.NCA.NCALR.Shirt.ShirtTemplate

-------------- GROUPS IDS
NCA = 11229664
IC = 11360623
FOC = 11360548
SFC = 11327219
SC = 11360552
TEC = 11360590

-------------- FUNCTIONS

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(Character)
		local NCA = plr.Team == BrickColor.Black()
		wait()
		
		if plr:GetRankInGroup(NCA) >= 180 then -- NOT DONE DON'T TOUCH
			Character.Shirt.ShirtTemplate = NCASHR
			Character.Pants.PantsTemplate = NCAPHR
		elseif plr:GetRankInGroup(NCA) <= 180 then
			Character.Shirt.ShirtTemplate = NCASLR
			Character.Pants.PantsTemplate = NCAPLR
		end
	end)
end)

I’ve tried a few things but it seems to not work I think it’s a
Roblox problem.
The same for the pants in the picture that was provided.
It’s working at the start when you join the game but when respawn it’s just breaks.

1 Like

Try CharacterAppearanceLoaded and verify that the shirt is there because not everyone does not have it.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(function(Character)
		local NCA = plr.Team == BrickColor.Black()
		
		local Shirt = Character:FindFirstChildOfClass("Shirt")
		if plr:GetRankInGroup(NCA) >= 180 then
			if Shirt then        Shirt.ShirtTemplate = NCASHR        end
			Character.Pants.PantsTemplate = NCAPHR
		elseif plr:GetRankInGroup(NCA) <= 180 then
			if Shirt then        Shirt.ShirtTemplate = NCASLR        end
			Character.Pants.PantsTemplate = NCAPLR
		end
	end)
end)

Try adding a WaitForChild():

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

local uniforms = ReplicatedStorage.Uniforms

local NCASHR = uniforms.NCA.NCALR.Shirt.ShirtTemplate
local NCAPHR = uniforms.NCA.NCALR.Pants.PantsTemplate
local NCAPLR = uniforms.NCA.NCALR.Pants.PantsTemplate
local NCASLR = uniforms.NCA.NCALR.Shirt.ShirtTemplate

-------------- GROUPS IDS
NCA = 11229664
IC = 11360623
FOC = 11360548
SFC = 11327219
SC = 11360552
TEC = 11360590

-------------- FUNCTIONS
Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(Character)
		local NCA = plr.Team == BrickColor.Black()
		local Shirt, Pants = Character:WaitForChild("Shirt"), Character:WaitForChild("Pants")

		if plr:GetRankInGroup(NCA) >= 180 then -- NOT DONE DON'T TOUCH
			Shirt.ShirtTemplate = NCASHR
			Pants.PantsTemplate = NCAPHR
		elseif plr:GetRankInGroup(NCA) <= 180 then
			Shirt.ShirtTemplate = NCASLR
			Pants.PantsTemplate = NCAPLR
		end
	end)
end)
2 Likes

Works how I haven’t thought about that thank you.