Turning Off A Bunch Of Lights With One Local Script

Hello i am making my time local, but my street lights don’t turn on at night because they are still operating on the server not the client how would i make a local script that turns all of then on at once?

Server Sided Light Scripts (this script is in every street light.)

    while true do
    	wait(1)
    	if game.Lighting.TimeOfDay >= "18:00:00" then
    		script.Parent.SpotLight.Enabled = true
    	elseif game.Lighting.TimeOfDay >= "07:00:00" then
    		script.Parent.SpotLight.Enabled = false
    	end
end

Client Sided Time Script

local cycleTime = dayLength*60
local minutesInADay = 24*60

local lighting = game:GetService("Lighting")

local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime

local timeRatio = minutesInADay / cycleTime

if dayLength == 0 then
	dayLength = 1
end

repeat
	local currentTime = tick()
	
	if currentTime > endTime then
		startTime = endTime
		endTime = startTime + cycleTime
	end
	
	lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
	wait(1/15)
until false

Thanks -Meeskop

1 Like

I’d recommend moving the time script to the server. Unless it’s necessary that new players have the time be set to a certain value, your current scripts are already sufficient to achieve the effect you’re looking for.

CollectionService. (30 characters)

Its local because i have different time settings