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

How would you make something happen at a certain time of day?

Asked by 8 years ago

So, I want to make a TV that shows a different TV show (aka a set of decals and audio) at different times of day.

But I can't figure out how the heck I would make them appear at certain times of day! I'm guessing I would use this code:

if GetMinutesAfterMidnight() == 18:00:00
then
--(set to a certain decal and audio)

I know there is an error in this and I'm a bit new to scripting, so I can't figure this out. Any help is appreciated :)

0
Minutes after midnight is literally the amount of minutes after midnight, so 18:00:00 is 18 * 60 minutes or 1080 minutes Sublimus 992 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Problem 1:

The ':' operator cannot be in a number value.

And if it did use ':', it would be a string.


Problem 2:

Like what Sublimus said in the comments, the returned value that you want would be 1080.


Problem 3:

GetMinutesAfterMidnight() is a method, not a global function, so you need to call it like this:

game.Lighting:GetMinutesAfterMidnight()


Now, to actually make something happen after it returned true, you would put the code in the if statement, like so:

while wait(60) do -- repeats every minute, change this to how long your minutes are, in game. Most scripts add a minute a second or the like, so it would be wait(1)
    if game.Lighting:GetMinutesAfterMidnight == 1080 then
        -- code
    end
end

I put the while loop in there because if statements only run once.

0
Thanks so much SPBOnion 30 — 8y
0
np TheDeadlyPanther 2460 — 8y
Ad

Answer this question