Script doesnt change TextLabel

I made a localscript in a gui that counts the players on the hunter team, it print the (#playerCount…" Hunter/s) but it doesnt change the TextLabel

--//Service
local teamService = game:GetService("Teams")
local Hunter= game.Teams["The Hunters"]

--//Components
local text = script.Parent.Frame.Roundify.Number

--//Script

local function changeNumber()
	local playerCount = HunterTeam:GetPlayers()
	print(#playerCount.." Hunter/s")
	text.Text = #playerCount.."/4"
end

HunterTeam.PlayerAdded:connect(changeNumber)
HunterTeam.PlayerRemoved:connect(changeNumber)

Same issue here, easy to fix.

Variables for texts don’t work on me too.

Try this:

–//Service
local teamService = game:GetService(“Teams”)
local Hunter= game.Teams[“The Hunters”]

–//Components
script.Parent.Frame.Roundify.Number

–//Script

local function changeNumber()
local playerCount = HunterTeam:GetPlayers()
print(#playerCount…" Hunter/s")
script.Parent.Frame.Roundify.Number.Text = #playerCount…“/4”
end

HunterTeam.PlayerAdded:connect(changeNumber)
HunterTeam.PlayerRemoved:connect(changeNumber)

Hope it works, make sure to mark as a Solution if it helped!

1 Like

Sadly it doesnt work, it doesnt throw any error in the output, but thanks.

Your problem here is that you reference “The Hunters” team with a variable named Hunter in your code, but then you try to reference them as HunterTeam in the middle of your code. Either change variable’s name to HunterTeam from the start or change any other HunterTeam in your code to Hunter.

1 Like

I fixed that, but it still doesn`t work.

This might not help, but there isnt a space after Hunter in the line
local Hunter= game.Teams[“The Hunters”]

That shouldn’t cause any problems in code since Lua/Luau is not whitespace sensitive.

oh ok sorry I didn’t know that

You need to set a value inside the script before setting the text itself.

`local newtext = “your text here”

textbox.Text = newtext`

I also had this issue in the past, I realized it’s related to how information is stored when editing the text box’s Text value.

Try this.

text.Text = "".. #playerCount .. "/4"

You should not use the deprecated version of connect, use Connect with a capital C instead.