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

How do i call a function after a timer is up?

So i am trying to make a loading screen or waiting screen. The screen shows a timer that counts down till 0 from 20. I want to make a play button appear once the timer is has reached 0. How would i do that?

--Script that counts down from 20
local frame = script.Parent.Parent
local play = script.Parent.Parent.TextButton
local timer = script.Parent


for count = 20, 0, -1 do
	wait(1)
	timer.Text = (count)
end

Locations

--timer location
script.Parent.timer
--Frame Location
script.Parent
--Play button location
script.Parent.TextButton

Location of all my guis

https://imgur.com/a/4K7WkTZ

1 answer

All you need to do is create an if statement to see when the count reaches zero, then make the button visible.

local frame = script.Parent.Parent
local play = script.Parent.Parent.TextButton
local timer = script.Parent

for count = 5, 0, -1 do
	wait(1)
	timer.Text = (count)
	if count == 0 then --When timer reaches 0
		play.Visible = true --Make play button visible
	end
end

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