b=script.Parent local G,t=6,20 local q,U=17,45 local O=game:service("\076\105\103\104\116\105\110\103")if t==nil then t=0 end if U==nil then U=0 end function TimeChanged()local j=(G+t/60)*60 local c=(q+U/60)*60 if j<c then if O:GetMinutesAfterMidnight()>=j and O:GetMinutesAfterMidnight()<=c then b.Enabled=false else b.Enabled=true end elseif j>c then if O:GetMinutesAfterMidnight()>=j or O:GetMinutesAfterMidnight()<=c then b.Enabled=false else b.Enabled=true end end end TimeChanged()game.Lighting.Changed:connect(function(G)if G=="\084\105\109\101\079\102\068\097\121"then TimeChanged()end end)
--This script turns the light on at night and off in in the day!

b = script.Parent

local oh, om = 6, 20 -- Open Time (hours,minutes)
local ch, cm = 17, 45 -- Close Time (hours, minutes)

local l = game:service("Lighting")
if om == nil then
	om = 0
end
if cm == nil then
	cm = 0
end

function TimeChanged()
	local ot = (oh + (om / 60)) * 60
	local ct = (ch + (cm / 60)) * 60
	if ot < ct then
		if (l:GetMinutesAfterMidnight() >= ot) and (l:GetMinutesAfterMidnight() <= ct) then
			b.Enabled = false
		else
			b.Enabled = true
		end
	elseif ot > ct then
		if (l:GetMinutesAfterMidnight() >= ot) or (l:GetMinutesAfterMidnight() <= ct) then
			b.Enabled = false
		else
			b.Enabled = true
		end
	end
end

TimeChanged()
game.Lighting.Changed:connect(function(property)
	if property == "TimeOfDay" then
		TimeChanged()
	end
end)
