I’m trying to make my loop stop when SpleefTime == 0 or numberPlayersOnTeam == 1 or #players == 1
However, the loop only stops when SpleefTime == 0. numberPlayersOnTeam does not work or #players == 1
timeVal.Value = SpleefTimeDefault
repeat
timeVal.Value = SpleefTime
SpleefTime = SpleefTime - 1
task.wait(1)
until SpleefTime == 0 or numberPlayersOnTeam == 1 or #players == 1 -- Here
for i, v in pairs(Players:GetPlayers()) do
v.Team = game.Teams:WaitForChild("Lobby")
v:LoadCharacter()
end
This is not the entire script, it’s just the part I’m experiencing issues with.
Please let me know if you have any questions! I will be more than happy to answer them
Thanks!
Could you show me your “numberPlayersOnTeam” area of the script, Like how did you assign the variable? You might just have to add a “#” in front of it but I need to see the var to confirm
local doesn’t work how you expect it to work. It’s hard to explain so I’m not going to explain it.
Try this instead
timeVal.Value = SpleefTimeDefault
repeat
timeVal.Value = SpleefTime
SpleefTime = SpleefTime - 1
task.wait(1)
until SpleefTime == 0 or #game:GetService("Teams").Playing:GetPlayers() or #players == 1 -- Here
for i, v in pairs(Players:GetPlayers()) do
v.Team = game.Teams:WaitForChild("Lobby")
v:LoadCharacter()
end
btw #players is likely won’t work as well but I can’t replace it as I don’t know what did you define it as. Replace it like how I replace numberPlayersOnTeam
your value of playersOnTeam and player does not update try this
local Players = game:GetService('Players')
local playersOnTeam = game:GetService('Teams').Playing
timeVal.Value = SpleefTimeDefault
repeat
timeVal.Value = SpleefTime
SpleefTime = SpleefTime - 1
task.wait(1)
until SpleefTime == 0 or #playersOnTeam:GetPlayers() == 1 or #Players:GetPlayers() == 1 -- Here
for i, v in pairs(Players:GetPlayers()) do
v.Team = game.Teams:WaitForChild('Lobby')
v:LoadCharacter()
end