Really confused why it wont clone the correct nametag?

I’ve made this script that every time there character loads / resets it will get there team and according to there team it will clone a certain nametag to there head. Yet even if there team is “Alpha County Sheriffs” it stills gives them the citizen tag and prints that there a citizen.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		--Citizens
		game.Workspace:WaitForChild(player.Name)
		wait()
		local team = game.Players[player.name].Team.Name
		print(team)
		if team == "Citizens" then
			local tag = game.ReplicatedStorage:WaitForChild("TagCitizen"):Clone()
			tag.Rescale.name.Text = player.Name
			tag.Parent = character.Head
		elseif team == "Alpha County Sheriffs"  then
			local tag = game.ReplicatedStorage:WaitForChild("TagSheriff"):Clone()
			tag.Rescale.name.Text = player.Name
			tag.Rescale.rank.Text = "[000] "..player:GetRoleInGroup(5025931)
			tag.Parent = character.Head
		end
	end)
end)

Just to clarify, is the player changing teams in game or is it simply through automatically assigning the player to the team?

At the moment i’m just using the explorer to change my team and then set myself’s health to 0

Perhaps try using the autoassign property of the team (or whatever name it is, I forgot) to do so. Sometimes I’ve noticed that some actions were actually not affecting server, at least from before.

Messed around with changing the teams propertys, still no luck.

Pretty sure the problem lays in where the CharacterAdded function is only firing once when it is called from PlayerAdded. It may work if you tried to use CharacterAdded out of the PlayerAdded function, or if you applied PlayerAdded to teams.

Are you doing that from the client view or the server view?

1 Like

Thanks for telling me that, fixed the problem. :smiley: