Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is the value of increment on for loop not changing?

So I've been looking for tutorials on Youtube for a round system and I followed it correctly. So I'm trying to make a game like tower of hell. So whenever someone reaches the end the timer speeds up. Here's the code.


local function roundTimer ()
	while wait()do
		print(Timer.Value)
		for i = intermissionLength, 1, -1 do
			-- For loop for intermission
			roundStart.Value = false
			inRound.Value = false
			Timer.Value = -1
			wait(1)
			Status.Value = "Intermission: ".. i .." seconds left!"
		end
		for i = roundLength, 1, Timer.Value do
			-- For loop when people play the obby
			-- The value of timer is equal to -1 
			roundStart.Value = true
			inRound.Value = true
			wait(1)
			
			Status.Value = "Game: ".. i .." seconds left!"
			
		end
	end
end

Whenever I try to decrease "Timer" (The increment) to make its value -2 so that the timer will decrease faster, on the second for loop, when someone reaches the end it still decreases by -1. What do I do?

1 comment

0

Timer looks useless. change the "-1" in line 4 right before the "do" to -2, make a variable for that when someone reaches the end

1 answer

✓ Accepted answer

Make sure the for loops are out of the while true do loop.

local function roundTimer ()
        print(Timer.Value)
        for i = intermissionLength, 1, -1 do
            -- For loop for intermission
            roundStart.Value = false
            inRound.Value = false
            Timer.Value = -1
            wait(1)
            Status.Value = "Intermission: ".. i .." seconds left!"
        end
        for i = roundLength, 1, Timer.Value do
            -- For loop when people play the obby
            -- The value of timer is equal to -1 
            roundStart.Value = true
            inRound.Value = true
            wait(1)

            Status.Value = "Game: ".. i .." seconds left!"

        end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.