How to I make this work for each player?

This shows the player name and player level depends if he’s in police or criminal team. When I test this with 2 players and each player is in different team it doesn’t work, I know why but how do I fix that issue, local script and remote event ?

Here’s the script:

local Players = game:GetService("Players")
local RP = game:GetService("ReplicatedStorage")
local team = game:GetService("Teams")

local CriminalTags = RP.CriminalTags
local PoliceTags = RP.PoliceTags

local Criminal = game.Teams.Criminal
local Police = game.Teams.Police

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local head = char:WaitForChild("Head")
		
		local CriminalLevelText = CriminalTags.CriminalLevelText
		local CriminalNameText = CriminalTags.CriminalNameText
		
		local PoliceLevelText = PoliceTags.PoliceLevelText
		local PoliceNameText = PoliceTags.PolicerNameText
		
		local CriminalLevel = player.leaderstats.CriminalLevel
		local PoliceLevel = player.leaderstats.PoliceLevel

		CriminalTags.Adornee = head
		CriminalTags.Parent = head
		PoliceTags.Adornee = head
		PoliceTags.Parent = head

		CriminalNameText.Text = player.Name
		PoliceNameText.Text = player.Name
		
		CriminalLevelText.Text = "Lv: "..player.leaderstats.CriminalLevel.Value
		CriminalLevelText.TextColor3 = Color3.fromRGB(255, 183, 0)
		CriminalNameText.TextColor3 = Color3.fromRGB(255, 64, 0)
		
		PoliceLevelText.Text = "Lv: "..player.leaderstats.PoliceLevel.Value
		PoliceLevelText.TextColor3 = Color3.fromRGB(0, 234, 255)
		PoliceNameText.TextColor3 = Color3.fromRGB(0, 110, 255)
		
		CriminalLevel.Changed:Connect(function(changed)
			if changed then
				CriminalLevelText.Text = CriminalLevel.Value
			end
		end)
		
		PoliceLevel.Changed:Connect(function(changed)
			if changed then
				PoliceLevelText.Text = PoliceLevel.Value
			end
		end)
		
		if player.Team == Criminal then
			PoliceTags.Enabled = false
			CriminalTags.Enabled = true
		elseif player.Team == Police then
			CriminalTags.Enabled = false
			PoliceTags.Enabled = true
		end
	end)
end)

It seems you’re editing the tags directly. Try moving the tags variables under the PlayerAdded function and use their :clone() instead.

Now they’re not being visible in the game.

Nvm, it’s fixed thanks for help.

You were manipulating a single pair of tags (instead of cloning them for each player).

Provided the correct solution, please mark their reply as such.

1 Like