Could you not just use an if statement to detect when it reaches the time limit (and break the loop however this should not be a problem as you got the wait() in the while loop.
You could stop the while loop when reaching certain time of lighting, very basic example:
local StopNow = 17 -- Time to stop
local Step = 0.01 -- wait time for each update
local timechange = 1
while game.Lighting.ClockTime < StopNow do
game.Lighting.ClockTime = game.Lighting.ClockTime + timechange
wait(Step)
end
print("Loop Stopped")
local Step = 0.01 -- wait time for each update
local timechange = 1
local stopTime = 1
while stopTime < 5 do
stopTime += 1
game.Lighting.ClockTime = game.Lighting.ClockTime + timechange
wait(Step)
end
Sure, the variable called “stopTime”, is a number 1.
Each time the while loop repeats, sums 1 to stopTime variable, and the while loop will run only if stopTime is less than 5, after 4 times the while loop repeats, the stopTime variable will reach 5, and 5 is not less than 5, then the while loop will stop.
The statement is: while the variable stopTime is less than 5, continue, else it breaks.