Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

3 comments

0

I noticed you changed the title to solved. If my answer helped, would you please mark it as correct?

1

Lol, in it for the "Accept Answer" aren't ye?

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.

1 answer

✓ Accepted answer
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

This discussion is preserved as it was. New answers, comments, and votes are closed.