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

Issues with making a time of day script?

Asked by 9 years ago

So, I'm making a script that gradually increases the time of day until the time hits 10:00:00. Here's the script:

local ToD = game.Lighting.TimeOfDay
repeat
wait(0.1)
    ToD:SetMinutesAfterMidnight(ToD:GetMinutesAfterMidnight() + 1)
until ToD == "10:00:00"

The problem is that the output says GetMinutesAfterMidnight() is a nil value and the script breaks.

Output: 14:38:18.338 - Workspace.darkness:4: attempt to call method 'GetMinutesAfterMidnight' (a nil value)

I have no idea what's wrong with this script, but I bet some of you guys can help me with this.

1
You are attempting to call 'GetMinutesAfterMidnight' on 'TimeOfDay', not 'Lighting', consider changing to [game.Lighting:GetMinutesAfterMidnight] 'same with [SetMinutesAfterMidnight'. TheeDeathCaster 2368 — 9y
0
Oh, ok. I'll try it out. whyOmustOitObeOme 7 — 9y

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

GetMinutesAfterMidnight and SetMinutesAfterMidnight are both methods of Lighting, not TimeOfDay. It is also generally a bad idea to set a variable to a property, because the variable becomes what the property equals and is in no way connected to the property.

repeat
    wait(0.1)
    game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight() + 1)
until game.Lighting.TimeOfDay == "10:00:00"
Ad

Answer this question