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

How do I turn a light on with a specified timer?

Asked by
Myuuckn -5
9 years ago

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)

0
You have to provide some code, or show some sign of effort, this is NOT and request site dragonkeeper467 453 — 9y
0
WELL IDK HOW TO SCRIPT OK LOL THIS IS MEANT TO HELP PEOPLE WHO DONT KNOW HOW TO SCRIPT, GOD DANG Myuuckn -5 — 9y

1 answer

Log in to vote
0
Answered by
funyun 958 Moderation Voter
9 years ago

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.

Ad

Answer this question