Why is the number not updating?

Does anyone know why the number is not updating on the label?

Here is the Code:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService("Players")
local Status = ReplicatedStorage:WaitForChild("Status")
local TeamFrame = script.Parent.Parent.StarterGui.ScreenGui.mFrame.ArenaFrame.ArenaOFrame.TeamFrame.StatusLabel

while TeamFrame.Visible do
    local function Update()
	Status.Value  = "Waiting For Players ("..(#Players:GetPlayers())..")"
	repeat wait(1) until game.Players.NumPlayers == 8
	Status.Value = "Game Start!"
	local plrs = {}
	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
     wait (2)
1 Like

There should be an error along the lines of Passed value is not a function.

When you are connecting you are connecting the result of Update which is nothing, causing the error. () calls the function.


Also this…

repeat wait(1) until game.Players.NumPlayers == 8

This is polling. which isnt a good practice especially on roblox when we have events. Also this code should be waiting for a player to join not just every second.

A “mix” of polling and events, but better:

while (#Players:GetPlayers() < 8) do
    -- numPlayers is deprecated
    Players.PlayerAdded:Wait(); -- *wait* for a player to join

You’re also referencing the gui in startergui not the player gui.

1 Like

How would I reference the player gui in the server?

You don’t. You should be updating text and interface in general locally. Server should never touch or handle user interface/user input.

The client should be listening for when the status value changes, to change the text to the status value. The status value should be changed on the server. So that the client can update their gui’s text


ok so I have the client listening for the status value with this:

local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")

script.Parent.Text = Status.Value

	script.Parent.StatusLabel.Text = Status.Value

So where do I put the other script?

You change script.Parent.Text but in the function you change script.Parent.StatusLabel.Text

-- Server Code
local Status = game.ReplicatedStorage:FindFirstChild("Status") or game.ReplicatedStorage:WaitForChild("Status", 100);

local Con = game:GetService("RunService").Stepped:Connect(function()
    if #game.Players:GetPlayers() >= 8 then
         Status.Value = "Game Start!"
         Status.Value = "Waiting For Players, Current Count: ".. (#game.Players:GetPlayers())

And generally it would go some where in ServerScriptService, this is simply how I’d handle the server code.

I did put it in script service but I was just asking how I would update the PlayerGui, like if I need to put it in a different place

If the localscript is under the gui it will be cloned with the gui into the playergui and update said gui

1 Like

Yes the local script is already under the gui, I meant if I need to change where the server script was.

The server script, should be fine in ServerScriptService, sorry for confusing you :smile:

Why put the the whole function in a variable named “Con”?

Well you see, the reason I’d do that is so I can disconnect it later when the game has started. “Con” is just short for Connection; Con:Disconnect() would disable said connection. Just a personal habit I use, if I don’t think I’ll be using it later.

Ok, well I’m still having the problem where the number is not updating. I even changed script.Parent.StatusLabel.Text to just script.Parent.Text. Am I supposed to switch the content of the scripts to the other?

Easiest way to explain it is by giving an example, so uh.TestPlace.rbxl (18.8 KB)

1 Like

So I get this…but what I’m trying to do is wait until something is visible. Sorry I should have said this earlier

while TeamFrame.Visible do
	script.Parent.Text = Status.Value


repeat wait() until GuiObjectReferenceHere.Visible
--above line should yield code until it's visible