What I Want
I Want To Make A Timer So If There Isn't Enough Players It Loops The Repeat Loop Again.
Problem
It Subtracts By 2 to 5
Solutions
I've Added If Time Value Is Lower Than 0 Then Do This But That Didn't Work.
Game Script
repeat eventTable[2]:FireAllClients(player) wait(2) until #Player:GetChildren() >= 9
Gui Script
function CountDown(player) local Time = this.WaitingGuis.Stat.BG.Seconds local BG = this.WaitingGuis.Stat.BG repeat Time.Value = Time.Value - 1 BG.Loading.Text = Time.Value wait(1) until Time.Value == 0 end
Looping is completely fine and works great HOWEVER there is a better way to do it for better performance. Instead of using
repeat
you can use OnValueChanged like this if your using a value as the number of players. Change
ServerStorage.NumberValue.Changed:Connect()
to wherever the value is located and called.
ServerStorage.NumberValue.Changed:Connect() if #Player:GetChildren() >= 9 then -- run your code here else
repeat eventTable[2]:FireAllClients(player) -- don't need the player variable here (does nothing bc you did fireallclients) wait(2) until #Player:GetChildren() >= 9
-
function CountDown(player) -- player here is also useless as you don't use it (also could just do game.Players.LocalPlayer local Time = this.WaitingGuis.Stat.BG.Seconds local BG = this.WaitingGuis.Stat.BG repeat Time.Value = Time.Value - 1 BG.Loading.Text = Time.Value wait(1) until Time.Value == 0 -- make it until Time.Value <= 0 so if it goes under 0 before it checks, it will still end end