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

Help with For loops?

I was trying to make a Countdown function that counts down from one number to another,using two arguments,but it isn't doing that instead it just prints 1.Why and how do I fix it?

IsGame = false--Is there a game that has started? no
GameModes= {"Tag","Run","Idk"}
------------------------------
function Countdown (NumberStart,NumberEnd)
	for i = NumberStart,NumberEnd do
		return i
	end
end
function StartMinigame()
	local Count = Countdown(1,10)
	print(Count)
end
StartMinigame()

1 answer

✓ Accepted answer

I see, it only counts down once try this

function countdown(starttime, endtime)
	for i = starttime, endtime do
		wait(1)
		print(i)
	end
end

It doesnt need to be returned.

3 comments

0

But I want it in a function so I won't have to make a for loop each time   :s

0

ah, then here :)

0

editted answer

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