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 turn a light on with a specified timer?

So I'm making a project called Lights On, where basically you have to hide in the darkness for 60 seconds and after 60 seconds the lights turn on and a monster is after you and then you have 3 more minutes to survive, once you survive you get 10 points.

So after 60 seconds, the lights turn on, how do I do that? I'd really appreciate your help :)! (idk how to script)

2 comments

0

You have to provide some code, or show some sign of effort, this is NOT and request site

0

WELL IDK HOW TO SCRIPT OK LOL THIS IS MEANT TO HELP PEOPLE WHO DONT KNOW HOW TO SCRIPT, GOD DANG

1 answer

Let's try this approach.

t = math.floor(tick())
seconds = 10

while math.floor(tick()) ~= t + seconds do
	wait(.5) --So it doesn't lag so much
end

print("The time has come.")

tick() is a function that returns how many seconds have passed since January 1, 1970. That's not important to know. What's important is that we can use this to get differences in time.

t1 = tick()
wait(10)
t2 = tick()
print("Around "..math.floor(t2 - t1).." seconds have passed.")

That's 10 seconds that have passed. The while loop keeps waiting until the time passed since "t" is 10.

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