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

Change Time of Day using a Button?

Hello, I was wondering if there was an easy way to make it so when a player clicks a button it changes the time of day?

2 comments

0

You can either change it locally, or globally (replicate to all other connected Clients). All you have to do is adjust the 'ClockTime' property of lighting upon a 'MouseButton1Click' signal fire from your GUIButton. Or alternatively, set up a RemoteEvent Instance in ReplicatedStorage, and have the Server adjust the time.

0

Thank you!

1 answer

This is easy

Requirements: UI Button

Add a server script into the button

add this script into it

local timeOfDay = game.Lighting.TimeOfDay
local IsNight = false

script.Parent.MouseButton1Click:Connect(function()
	if IsNight == false then
		IsNight = true
		timeOfDay = 0
	else
		IsNight = true
		timeOfDay = 14
	end
end)

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