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

Please help me with changing my games ToD?

Asked by 9 years ago

I tried this:

while true do
    wait(30)
    script.Parent.TimeOfDay = +1
end

I simply just want the ToD to go up once. It would not function properly. Help?

1 answer

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

Well, there are several problems with this script, especially if this script is stored in Lighting.

  • 1) Lighting is one of those Services where, you can not run scripts, just like StarterGui, StarterPack, ServerStorage, and other services. If your script is parented to it, then it will never work.

  • 2) TimeOfDay is a string as mentioned in the Lighting Wiki Article.

    string TimeOfDay The sky's current phase based on a string representation of a 24 hour clock.

  • 3) On line 3, you're adding 1 to nothing, so it will be natural the script will error out due to trying to use arithmetic on a nil value.


Try putting this script into ServerScriptService or Workspace, this script will use SetMinutesAfterMidnight in order to get the results desired;

hour = 0 --This is based off
while wait(30) do --The script will run every 30 seconds.
    hour = hour + 1 --So a hour has passed in 30 seconds, this can easily be adjusted by changing the wait time, or the 1 in the equation.
    game.Lighting:SetMinutesAfterMidnight((hour*60)) --There are 60 minutes in a hour, so it will multiply hour by 60 otherwise you'll only get minutes past midnight.
end --Show the script that is the end of the loop and keep running it.
Ad

Answer this question