#Simple loops
25 messages · Page 1 of 1 (latest)
It's a normal script
If it's hard to understand, i have a function and all i wanna do is without affecting the function i want the function to end if there is not enough players ( i know how to detect the players etc ) but not how to end the function etc.
** You are now Level 5! **
local AmountOfPlayers
local Time = 150
game.Players.PlayerAdded:Connect(function(Plr)
AmountOfPlayers += 1
end)
game.Players.PlayerRemoving:Connect(function(Plr)
AmountOfPlayers -= 1
end)
while wait(1) do
Time -= 1
if AmountOfPlayers < (Minimum Players) then
break
end
end
Thjis is not what i want.
in the example here:
local function ExampleFunction()
task.wait(150)
end
In this function you can see a 150 timer, it's say it's half way through but a player leaves.
I dont want it to wait for it to end, i want to end the function intantly. without waiting
playerLeft= false
counter =0
game.Players.PlayerRemoved:Connect(function(player)
playerLeft= true
end)
function after()
print("after")
end
while task.wait(1) do
if playerLeft then
playerLeft= false
counter = 0
break
end
counter += 1
if counter == 150 then
after()
end
That's for this example, but i have a function without that "wait(150)" seconds just a long function with stuff, waits, etc..
Which means counters will not work.
I dont think u can
There's a game named "courtroom" that has waits and etc..
And when the player requirement is not met it completely cuts off everything and ends the function Idk how they do it
u can add a
if playerLeft then
return
end
at each line but it s ugly
this one
ends
every 1 second it checks
if minimum is exceeded
then it breaks the timer
Yes but as stated before, my code is not a timer, i used the timer as an example
For now yes