(Fully aware there is probably a better method but I’m new and this project is expanding my knowledge gradually and any options for a replacement that improves on this is welcomed with open arms.)
while true do
wait(2)
game.Lighting.Brightness = game.Lighting.Brightness + .1
if game.Lighting.ClockTime == 0 then
game.Lighting.Brightness = 0
end
end
How would I make this work? At the moment Brightness won’t change depending on ClockTime which means brightness will just increase until you’re blind.
The ClockTime will likely never be exactly midnight so this won’t work as you’ll never reset the brightness to 0. You could try this instead:
local Lighting = game:GetService("Lighting")
local function updateLighting()
Lighting.Brightness = Lighting.ClockTime / 24
end
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(updateLighting)
This code defines a function called updateLighting which will set the brightness whenever it’s called. We then use GetPropertyChangedSignal to call the function whenever ClockTime changes. In the function, we set the brightness to ClockTime / 24, which (as long as the time is between 0 and 24) will increase the brightness from 0 to 1 as the day goes on.
However this is not really realistic, so maybe look into using something like this inside the function: