How do i make time stop from accelerating after a certain time limit

Hi, im trying to make time stop from accelerating after a certain time limit its for a game im making
i dont know how
thanks in advance if you helped :slight_smile:

local Time = 0.01
		local timechange = 1
		while wait(Time) do
			game.Lighting.ClockTime = game.Lighting.ClockTime + timechange
		end
1 Like

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")

what im trying to say is after the time had looped for 3 times or 4 the loop will break
at a certain time in its 3-4 loop

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

Thanks , but could you explain how this script works?

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.