Hello! I am in need of a script that changes the Fog colour during certain time periods. This is to create a render distance effect. Here’s what 4 different times look like when the fog is white (why I want to change the fog at different times):
If you didn’t want players to see out of the map, you could adopt something similar to SharkBite and and a physical barrier or just increase the waters so far as they could not see the end (with an invisible wall).
As Dominus said, you could just increase the size of the water, but it would decrease the performance. I would suggest adding blocks with slight transparency, so it creates a fog like effect.
Here i came up with a simple script. Put it into a script in the blocks. You may need to adjust the colors and times tho.
while true do
if game.Lighting.TimeOfDay = "6:00:00" then -- Daytime
script.Parent.BrickColor = BrickColor.new("White") else
if game.Lighting.TimeOfDay = "19:00:00" then -- Nighttime
script.Parent.BrickColor = BrickColor.new("Black")
end
That’s not a script for brick mate. The script makes using color simply. Put the script in a brick and set the color of the brick with the color of fog you want.
I just figured that out, and know how to change it:
while true do
if game.Lighting.TimeOfDay = "6:00:00" then -- Daytime
script.Parent.BrickColor = BrickColor.new("White") else
if game.Lighting.TimeOfDay = "19:00:00" then -- Nighttime
script.Parent.BrickColor = BrickColor.new("Black")
end
But I still need more options than just night and day? Also more colour options would be nice. (Colour hex)
You can grab the best colour for each time and then interpolate between. I have a function for it in my.own game, however it has slightly different lighting to the default so the colours won’t necessarily match yours perfectly.
The best thing you can do is set the clock to some key times where the colour starts and finishes changing and record the best colour that matches it. Particularly during sunrise as the sky changes colour a couple of times. Sunset is easier as it goes orange, purple, black.
I’ll grab the code for you when I next get chance.
In future, the best thing you can do is to give it a try yourself and post a topic in #help-and-feedback:scripting-support, as you will find better help and working code snippets there. The code snippets in this topic are full of syntax and logical errors, but I can see you’ve given it a go so I’m happy to share this with you:
local Lighting = game:GetService( 'Lighting' )
local FOG_COLOURS = {
[ 'black' ] = Color3.new( 0, 0, 0 ),
[ 'dark_blue' ] = Color3.fromRGB( 34, 40, 58 ),
[ 'early_orange' ] = Color3.fromRGB( 69, 60, 62 ),
[ 'early_purple' ] = Color3.fromRGB( 52, 41, 63 ),
[ 'light_blue' ] = Color3.fromRGB( 180, 210, 228 ),
[ 'late_orange' ] = Color3.fromRGB( 72, 61, 42 ),
[ 'late_purple' ] = Color3.fromRGB( 50, 38, 63 ),
}
function getFogColour( minutes )
if type( minutes ) ~= 'number' then
return FOG_COLOURS.light_blue
end
local hours = minutes / 60
if hours <= 3 or hours >= 21 then
return FOG_COLOURS.black
elseif hours > 3 and hours <= 4 then
return FOG_COLOURS.black:lerp( FOG_COLOURS.dark_blue, hours - 3 )
elseif hours > 4 and hours <= 5.5 then
return FOG_COLOURS.dark_blue:lerp( FOG_COLOURS.early_orange, ( hours - 4 ) / 1.5 )
elseif hours > 5.5 and hours <= 6 then
return FOG_COLOURS.early_orange:lerp( FOG_COLOURS.early_purple, ( hours - 5.5 ) / 0.5 )
elseif hours > 6 and hours <= 6.5 then
return FOG_COLOURS.early_purple:lerp( FOG_COLOURS.light_blue, ( hours - 6 ) / 0.5 )
elseif hours > 6.5 and hours <= 17.5 then
return FOG_COLOURS.light_blue
elseif hours > 17.5 and hours <= 18 then
return FOG_COLOURS.light_blue:lerp( FOG_COLOURS.late_orange, ( hours - 17.5 ) / 0.5 )
elseif hours > 18 and hours <= 18.4 then
return FOG_COLOURS.late_orange:lerp( FOG_COLOURS.late_purple, ( hours - 18 ) / 0.4 )
elseif hours > 18.4 and hours <= 20 then
return FOG_COLOURS.late_purple
elseif hours > 20 and hours <= 21 then
return FOG_COLOURS.late_purple:lerp( FOG_COLOURS.black, hours - 20 )
end
end
Lighting:GetPropertyChangedSignal( 'TimeOfDay' ):Connect( function()
local minutes = Lighting:GetMinutesAfterMidnight()
Lighting.FogColor = getFogColour( minutes )
end )
I’ve had a quick test and these colours do actually seem to match the default really closely. If there are any that are slightly off, you should be able to swap the colours after a bit of experimentation. I needed the fog colour to match the sky really closely in my game which is why it’s split into loads of different conditions based on the time in hours to get it as accurate as possible.
Let me know if you struggle to get the colours and I’ll try to help.
LocalScript is where it was for me, but shouldn’t make too much difference. Best to keep it on the client anyway.
Pop it in a LocalScript in ReplicatedFirst and it should work fine. I tested it before sending. You’ll need to change the time in Lighting using another script or manually to see the effect.
SUCCESS! Works like a charm, thank you so much! KIT, when I actually have Robux I’ll pay you 500 (or more idk bad at pricing) now to find out how to make it darker at night