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!"
wait(10)
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player)
end
end
wait (2)
end
Players.PlayerAdded:Connect(Update())
end
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.
Players.PlayerAdded:Connect(Update)
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
end
You’re also referencing the gui in startergui not the player gui.
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
-- 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!"
else
Status.Value = "Waiting For Players, Current Count: ".. (#game.Players:GetPlayers())
end
end)
And generally it would go some where in ServerScriptService, this is simply how I’d handle the server code.
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?