Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with For loops?

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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.

0
But I want it in a function so I won't have to make a for loop each time   :s kevinnight45 550 — 10y
0
ah, then here :) User#5978 25 — 10y
0
editted answer User#5978 25 — 10y
Ad

Answer this question