plr = game.Players.NumPlayers
while true do wait(.2)
if plr < 3 then script.Parent.TextColor = BrickColor.new("Really red") script.Parent.Text = ("False") else script.Parent.TextColor = BrickColor.new("Bright green") script.Parent.Text = ("True") end
end
-Issue- When the game has hit >= 3 players, the game mode shows "True" only on the 3rd player. On the other players it shows false. Please help!
if #game.Players:GetPlayers() > 3 script.Parent.TextColor = BrickColor.new("Really red") script.Parent.Text = ("False") else script.Parent.TextColor = BrickColor.new("Bright green") script.Parent.Text = ("True") end
You set the plr variable to the value of game.Players.NumPlayer. It's never going to change because it's just a copy of the number. In your while loop, you should be using game.Players.NumPlayer instead of plr.
However, there's an entirely better way to do this. Instead of polling every 0.2 seconds, you can just update the text whenever a player is added or removed from the Players service.
local Players = game:GetService("Players") function updateText() if Players.NumPlayers < 3 then script.Parent.TextColor = BrickColor.new("Really red") script.Parent.Text = ("False") else script.Parent.TextColor = BrickColor.new("Bright green") script.Parent.Text = ("True") end end updateText() Players.ChildAdded:connect(updateText) Players.ChildRemoved:connect(updateText)
Also, to get the number of something, you generally need to put a hash tag before the value, like this.
local Players = game.Players if #Players < 3 then -- CODE HERE end