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

How can I make a script activate when it is a certain time of day?

So lets say it was time 00:0000 (24), how could I make a script activate? Eg; Nightlights

1 answer

✓ Accepted answer

Hi, IPhoneDrew. The solution to your question, "How can I make a script activate when it is a certain time of day?", can be found on the Changing Time of Day – Making a Day/Night Cycle

-- This code is completely from the wiki linked above

lightPart = game.Workspace.LightPart
minutesAfterMidnight = 0
 
while true do
	minutesAfterMidnight = minutesAfterMidnight + 10
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
	wait(0.1)
 
	if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then		-- checks for 6AM
		lightPart.Material = Enum.Material.Plastic
		lightPart.PointLight.Enabled = false
	end
	if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then		-- checks for 6PM
		lightPart.Material = Enum.Material.Neon
		lightPart.PointLight.Enabled = true
	end
end

1 comment

0

Thank you!

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