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

How do you make when a Countdown Value hits 0, a function starts?

Asked by 3 years ago

I have tried a lot to try and make when a Countdown hits 0, a function named NewsStart will start. I can't get it to work. Can someone help me?

local Time = workspace.Number.Value

function NewsStart()
    script.Parent.Value = "NEWSTEXTHERE"
    wait(3)
    script.Parent.Value = "NEWSTEXTHERE2"
end

while Time 0 do
    NewsStart()
end

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

this should work using a for loop

--change time to the time you want it can be a variable or a number
for i = Time,0,-1 do
-- if you wanna change the value of something in the countdown like setting the text to the timers current seconds left then do that here
wait(1)
end
--when the loop is done/countdown is 0
Ad
Log in to vote
0
Answered by
Soban06 410 Moderation Voter
3 years ago

So what you will use is a for loop. Like this:

for i = 10, 0, -1 do
    if i == 0 then
        -- Run the function 
        NewsStart()
    end
wait(1)
end

Hope it helps.

Answer this question