Currently making a game and I want a script to wait before there are at least 4 players before it begins the round.
round = false local hint = Instance.new("Hint") while round == false do if script.Parent.val.Value < 5 then hint.Parent = game.Workspace hint.Text = "Waiting for Players" else hint.Parent = game.Workspace hint.Text = "Game Will Begin Shortly" round = true end end
val is the name of the value which contains the playercount number, it's working fine, whenever I change the intvalue to a number over 5, the script works and the game begins, however, when I try changing the intvalue during the game, It gets stuck on the "Waiting for Players" part.
To get a reading of how many players are in the game see how many children game.Players
has. This can be done as follows,
Ex.
local CurrentPlayers = game.Players:GetChildren() local PlayerCount = #CurrentPlayers
#
is used to get a count of how many values are in a table which we created with GetChildren. In this case the table is filled with each player’s instance.
if game.Players.NumPlayers > 3 then -- if the there is more than 3 players then -- Do whatever end