Code issues - Show teams player on textLabel.Text

Hello! I’m trying to show the number of players in my teams in my textLabel.Text, what am I doing wrong? They are not showing

image

image

localscript on StarterPlayerScripts:

local Teams = game:GetService("Teams")

-- Reference the player's PlayerGui
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local TPS_GUI = playerGui:WaitForChild("TPS WITH MICHROMA")

-- Reference the TextLabels inside the ImageLabels
local blueTeamLabel = TPS_GUI.Frame.Countdown.blueCounter:WaitForChild("textLabel")
local redTeamLabel = TPS_GUI.Frame.Countdown.redCounter:WaitForChild("textLabel")

-- Wait for teams to be created
local blueTeam = Teams:FindFirstChild("Blue Team")
local redTeam = Teams:FindFirstChild("Red Team")

if blueTeam and redTeam then
	-- Extract the first character of the player count for each team
	local blueChar = tostring(#blueTeam:GetPlayers()):sub(1, 1)
	local redChar = tostring(#redTeam:GetPlayers()):sub(1, 1)

	print(blueChar)
	print(redChar)

	local blueValue = blueChar
	local redValue = redChar

	-- Update the TextLabels with the first character
	blueTeamLabel.Text = blueValue
	redTeamLabel.Text = redValue

	print("Team 1 Players: " .. #blueTeam:GetPlayers())
	print("Team 2 Players: " .. #redTeam:GetPlayers())
else
	warn("One or both teams not found.")
end

It seems that you’re using WaitForChild incorrectly here:

local blueTeamLabel = TPS_GUI.Frame.Countdown.blueCounter:WaitForChild("textLabel")
local redTeamLabel = TPS_GUI.Frame.Countdown.redCounter:WaitForChild("textLabel")

because it’s looking for an instance named “textLabel” and from your screenshot the Text Label is named “Text”, therefore the script never gets past this point.

I have modified it and it should work but it still doesn’t work, what could be wrong?

this still shows the default 2/3 :confused: