How to slowly change lighting brightness depending on clocktime?

this script im trying to do to change the brightness slowly depending on the times, no errors but does not work

l = game:service("Lighting") 
b =  l.Brightness
while true do
	if script.Halloween.Value == false then
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+1)
if l.ClockTime >= 17.5 and l.ClockTime <= 6 and l.Brightness <= 5 then
	print("brightness up")
			b = b + 0.1
	else
		if l.ClockTime <= 17.9 and l.ClockTime >= 6 and l.Brightness >= 1.36 then
				print("brightness down")
		   b = b - 0.1
		end
		end
		wait(1) 
	else
		if script.Halloween.Value == true then
			game.Lighting:SetMinutesAfterMidnight(1 * 3)
			game.Lighting.Ambient = Color3.new(1, 0, 0.0156863)
		end
	end
end

Try this

l.Brightness += .1
--Or
l.Brightness -= .1

Replace the parts where you increment up or down with the ones I showed you

doesnt work unfortunately aaaaaaaaaaa

assigning l.Brightness to a variable makes a copy of the brightness value, so youre just changing a random number in the games memory instead of the actual brightness

local lighting = game:GetService("Lighting")
--to change brightness:
lighting.Brightness = 1

still kinda confused? no error but no print either

local lighting = game:GetService("Lighting")
while wait(1) do
	if script.Halloween.Value == false then
		lighting:SetMinutesAfterMidnight(lighting:GetMinutesAfterMidnight()+1)
		if lighting.ClockTime > 17.5 and lighting.ClockTime < 6 and lighting.Brightness <= 5 then
	print("brightness up")
			lighting.Brightness += 0.1
	else
			if lighting.ClockTime < 17.9 and lighting.ClockTime > 6 and lighting.Brightness >= 1.36 then
				print("brightness down")
				lighting.Brightness -= 0.1
	else
		if script.Halloween.Value == true then
			game.Lighting:SetMinutesAfterMidnight(1 * 3)
			game.Lighting.Ambient = Color3.new(1, 0, 0.0156863)
		end
	end
	end 
	end
end

lighting.ClockTime > 17.5 and lighting.ClockTime < 6
impossible

There’s a way better way to do what you’re trying to do. Instead of trying to manually calculate the brightness using math, create a number/color curve and set the values of the curve to what you want them as when it hits a certain clock time.

Example of brightness curve:

Example of color curve:
image

You can store these number and color curves as an attribute under any instance. To calculate the color/brightness at a certain time, use:
(lighting.ClockTime/24) --[Example, ClockTime = 12 | 0.5]

If you need an example of how to set up these curves and how you would access these values, let me know.

wait so im confused, iv touched with attributes before, but still a little new to it. Could i get that example?

Here’s the folder that contains different “Configuration” instances. Inside each configuration, there’s a Brightness Curve and Color Curve. To figure out how to use these values, go to this document, it includes a method called evalNumberSequence.

LightingSettings.rbxm (914 Bytes)

Specifically for your use case, you should determine if it’s a “special” day (example: Halloween) and if it is, point to the Halloween instance, if not, point to the normal instance and set Lighting properties using the Attributes gotten from the Sequences/curves. Hope this helps. :slight_smile:

2 Likes

Im gonna look into this right now, ill get back to you, thank you!

1 Like

Just got to looking at this, The brightness/color sequence how do i set the numbersequence and detect it from the clock?