TextLabel not showing player's team

The text label I have that is supposed to show the player’s team isn’t working. The rank and name work fine, however I am having issues with the team part.

Code:

local frame = ui.Frame
	local VisitorColour = Color3.fromRGB(163, 162, 165)
	local StudentColour = Color3.fromRGB(248, 248, 248)
	local StaffColour = Color3.fromRGB(13, 105, 172)
	local CouncilColour = Color3.fromRGB(128, 187, 219)
	
	game.Players.PlayerAdded:Connect(function(plr)
		plr.CharacterAdded:Connect(function(chr)
			team.Text = plr.Team
			if plr.Team == "Visitor" then
				team.TextColor3 = VisitorColour
			elseif Player.Team == "Student" then
				team.TextColor3 = StudentColour
			elseif Player.Team == "Staff" then
				team.TextColor3 = StaffColour
			elseif Player.Team == "Council" then
				team.TextColor3 = CouncilColour
			end
		end)
	end)

[ui is a pre-defined variable that I use through the whole script, I use it for the player’s name and rank and it works fine.]

What did you define “team” as? Is it a text label?

Hey there, I answered a question similar to this. You’re not handling how players and characters are added in correctly:
CharacterAdded functions not loading correctly - Help and Feedback / Scripting Support - DevForum | Roblox

[Edit] you might also want to make sure you’re guaranteeing that the team is being set before you run this code, like so:

plr:GetPropertyChangedSignal("Team"):Connect(function()
    -- do code to adjust the team text again since our team changed
end)

This would happen outside of CharacterAdded and inside of PlayerAdded. You will also have to run your code if you do find a team right when the player was added.

yes it’s a text label

CHARACTERSSSSSSS

the functions are fine…

i’ll add the team changed function

I added the property changed function and now the gui doesn’t show up at all.

The way you’re handling PlayerAdded and CharacterAdded doesn’t handle any pre-existing characters or players upon execution. It’s not fine.

I can help you further if you share your implementation.