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

how to change daytime again?

I know it seems confusing, but i'm trying to make it after 180 seconds it changes back to noon, can anyone help?


local minutes = 0
local hours = 0

while true do
	game.Lighting.TimeOfDay = hours.."20:00:00"..minutes
--what is the changed time
	wait(script.WaitToAdd.Value)
	minutes = minutes + script.AddAmount.Value
	if minutes >= 60 then
		hours = hours + 1
		minutes = 0
		if hours >= 24 then
			hours = 0
		end
	end
end
--i wanted to change it back to 12:00:00.

3 comments

0

The problem's line 5. :P

0

TimeOfDay is a string and not a number :|

0

You can use tostring() to turn numbers into string

1 answer

Is this what you're trying to do?

local RunService = game:GetService("RunService")
local hb = 1/60

local length = 360 -- Set this to how long, in seconds, you want the whole day to last for (from midnight back to midnight again.)

while true do
	game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight() + ((1440/length) * hb))
	hb = RunService.Heartbeat:Wait()
end

1 comment

0

nah, i was thinking that like intermission when it switches to midnight at the end of the round it switches back to morning 12:00:00, i'm gonna try to incorporate it into my intermission script. thanks for helping!

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