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

How to work with and change Time Of Day?[SOLVED]

Asked by
tanzane 100
9 years ago

I have no idea how to change the time of day in a script. Like in some games, the time of day changes, eventually from day, it gets to the afternoon, from the afternoon, night. That's what I'm trying to do, how exactly would I change the time?

0
I noticed you changed the title to solved. If my answer helped, would you please mark it as correct? Merely 2122 — 9y
1
Lol, in it for the "Accept Answer" aren't ye? tanzane 100 — 9y
0
Not entirely, I'm trying to get better at explaining scripting concepts. Plus if anyone encounters this problem again and sees the post, it shows them which answer was helpful. Merely 2122 — 9y

1 answer

Log in to vote
2
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago
local Lighting = game:GetService("Lighting")

Lighting.TimeOfDay = "12:00:00"

TimeOfDay takes a string that represents the current time in hours, minutes, and seconds. You have to concatenate the numbers together into a string when setting TimeOfDay. Here's an example script that goes from night to day to night.

local Lighting = game:GetService("Lighting")
local seconds = 0

while true do
    for hours = 0, 23 do
        for minutes = 0, 59 do
            wait(0.1)
            Lighting.TimeOfDay = tostring(hours) .. ":" .. tostring(minutes) .. ":" .. tostring(seconds)
        end
    end
end
Ad

Answer this question