Realistic Lighting Script Help

Hello.

I am trying to create a day cycle that includes realism like shown in the GIFs below:
https://gyazo.com/d8f9e2926651ce5c3b73a1e3282200c5
https://gyazo.com/541e2dffc5f2cc97bde69a0a4d3967db - In this one, I turn off the Global shadows at a later point than I should’ve, but the idea is the same.

I’m trying to use Brightness and GlobalShadows to achieve this. My idea for how this script will work is that at 1 point in game time (e.g, 16:00), the brightness of the game will slowly decrease from 2 by a certain number (e.g 0.4) each second passes (tick), until the brightness is 0. It would reverse when the sun rises, going from 0, to the brightness being 2. Global shadows will also turn off when it is 0.

I’ve done the time script, which is SetMinutesAfterMidnight, however would the function .time also work for this? So if time > 18:00 then e.c.t

My script follows as this:

BR = game.Lighting.Brightness – BR stands for Brightness

l = game:service(“Lighting”)
while true do
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+0.5)
wait(0.05)
end

1 Like

…you aren’t asking a question here? All I see in this thread is an outline of what you want and expecting someone “helps” by providing the full code.

Realistically you shouldn’t be toggling GlobalShadows at run time, those are handled automatically. The distinction between indoor and outdoor areas also gets removed, which is counterproductive for a lighting system.

I think the rest should be self explanatory? Just make the brightness a percentage of the number between the starting time and the finishing time. The starting time is your 0%, your finish time is your 100%. If the number is between 16:00 and 00:00 for example (correct to 24 in a 24H scenario), then your division is by 8. Can be corrected for 200% (brightness of 2).

2 Likes