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

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

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

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

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.

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