Designing Day/Night system


#1

What I want to be able to do is to make a Day/Night script. Possibly a weather system intertwined with it.
I’m unsure how to make it. I know how the cycle works but the environment implementation is what I’m not too sure about, I’d assume I can use lerps or tweens. Additionally, I want to make use most of the resources available such as post processing effects and ColorShift.

Any ideas how to come across this?


#2

Should actually do some research before coming here asking questions that already have millions of answers to:
https://developer.roblox.com/articles/Day-Night-Cycles-and-Street-Lights


#3

Its not as advanced as I want it to be. I know the components how to make a basic script, I want to apply it more with the environment.

That link only shows how to change the time in a cycle.


#4

That could be the day-night cycle you’re looking for.
On the other hand, if you want weather and more complex things. You can separate that into another system which controls weather.
In that tutorial, it shows how you can link street lights with the day and night cycle. Instead, you can try linking it up with weather such as storms and such.

Sorry if that sounded confusing but I think you might get the point?


#5

Sorry, I didn’t make myself very clear. I understand how to do the cycle, its the implementation of these lighting effects is what I was looking for.


#6

Hmmm :thinking:

You could instead of linking with a street light like how it shows in the article, link it with weather like lightning.

Im also pretty sure there’s a module for lightning and rain.


#7

I feel like that article wouldn’t work as effectively for me.
Lighting is my biggest concern.


#8

Like lightning changing bricks, (if you never used those free models, you can try studying them) you can change it via finding the lighting and changing the properties by randomfying it, roblox even provides a tutorial on doing RNG :smiley: https://developer.roblox.com/articles/Random-Number-Generation

Using both that, you might be able to do that. Other than that though, I don’t really quite understand what you’re trying to do so hopefully this helps :stuck_out_tongue:

Edit: Top might sound confusing so basically, create a table where if its value 1, its stormy, if its value 2, its normal. Using RNG can randomize it to help with a more weatherly feel :3


#9

If changing the ambient is your biggest concern, you can always make a loop script and check the time occasionally and set the settings. Here’s how I did for the game on my beach.

local TweenService = game:GetService("TweenService")
local CycleTime = 360
local RandomStartTime = math.random(0, 24)
game.Lighting.ClockTime = RandomStartTime

local LightGoal = {}
LightGoal.ClockTime = 24
local LightStyle = TweenInfo.new(CycleTime*(RandomStartTime/24), Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
TweenService:Create(game.Lighting, LightStyle, LightGoal):Play()
delay(0, function()
	game.Lighting.ClockTime = 0
	local LightGoal = {}
	LightGoal.ClockTime = 24
	local LightStyle = TweenInfo.new(CycleTime, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1)
	TweenService:Create(game.Lighting, LightStyle, LightGoal):Play()
end)

local CurrentDayCycle = ""
while script do
	if game.Lighting.ClockTime >= 0 and game.Lighting.ClockTime < 6 then
		if CurrentDayCycle ~= "NightTime" then
			local AmbientGoal = {}
			AmbientGoal.FogColor = Color3.fromRGB(24, 42, 63)
			AmbientGoal.FogEnd = 7000
			AmbientGoal.FogStart = 50
			AmbientGoal.OutdoorAmbient = Color3.fromRGB(107, 107, 107)
			local AmbientStyle = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
			TweenService:Create(game.Lighting, AmbientStyle, AmbientGoal):Play()
		end
		CurrentDayCycle = "NightTime"
	elseif game.Lighting.ClockTime >= 6 and game.Lighting.ClockTime < 6.25 then
		if CurrentDayCycle ~= "SunRise" then
			local AmbientGoal = {}
			AmbientGoal.FogColor = Color3.fromRGB(146, 163, 114)
			AmbientGoal.FogEnd = 7000
			AmbientGoal.FogStart = 600
			AmbientGoal.OutdoorAmbient = Color3.fromRGB(127, 127, 127)
			local AmbientStyle = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
			TweenService:Create(game.Lighting, AmbientStyle, AmbientGoal):Play()
		end
		CurrentDayCycle = "SunRise"
	elseif game.Lighting.ClockTime >= 6.25 and game.Lighting.ClockTime < 17.75 then
		if CurrentDayCycle ~= "DayTime" then
			local AmbientGoal = {}
			AmbientGoal.FogColor = Color3.fromRGB(75, 129, 191)
			AmbientGoal.FogEnd = 10000
			AmbientGoal.FogStart = 1750
			AmbientGoal.OutdoorAmbient = Color3.fromRGB(136, 136, 136)
			local AmbientStyle = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
			TweenService:Create(game.Lighting, AmbientStyle, AmbientGoal):Play()
		end
		CurrentDayCycle = "DayTime"
	elseif game.Lighting.ClockTime >= 17.75 and game.Lighting.ClockTime < 18 then
		if CurrentDayCycle ~= "SunSetting" then
			local AmbientGoal = {}
			AmbientGoal.FogColor = Color3.fromRGB(146, 163, 114)
			AmbientGoal.FogEnd = 7000
			AmbientGoal.FogStart = 600
			AmbientGoal.OutdoorAmbient = Color3.fromRGB(127, 127, 127)
			local AmbientStyle = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
			TweenService:Create(game.Lighting, AmbientStyle, AmbientGoal):Play()
		end
		CurrentDayCycle = "SunSetting"
	elseif game.Lighting.ClockTime >= 18 and game.Lighting.ClockTime <= 24 then
		if CurrentDayCycle ~= "NightTime" then
			local AmbientGoal = {}
			AmbientGoal.FogColor = Color3.fromRGB(24, 42, 63)
			AmbientGoal.FogEnd = 7000
			AmbientGoal.FogStart = 50
			AmbientGoal.OutdoorAmbient = Color3.fromRGB(107, 107, 107)
			local AmbientStyle = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
			TweenService:Create(game.Lighting, AmbientStyle, AmbientGoal):Play()
		end
		CurrentDayCycle = "NightTime"
	end
	wait(2.25)
end

If the current ambient settings are off, you can always adjust it.

For doing weather, you can do what 3rdhoan123 and do a RNG for when rain happens or anything else, just make sure to add a cooldown and a bool value to make sure multiple weather effects don’t happen at the same time. Just make sure to adjust the lighting again if there’s certain weather effects. If you intend to add season-times like winter and summer, you will have to specific which season it is on and to determine which weather effects can be possible.


#10

Thanks for that!


#11

Before weather and such, start with the basics:

Here we made a Day/Night script that plays with lighting aswell.

You’ll have to run the game over and over just to get your desired effects right, it will take patience, but it will be worth it.


#12

Thank you :slightly_smiling_face:


#13

I was just going off what the title of the post is:
‘Designing Day/Night system’
as well as the first line in your post

:man_shrugging:


#14

Think its best you read the whole thread to be fair. Instead of reading the first few words.
That way you can fully understand what I’m trying to portray.


#15

Title should read ‘How to make a weather system’ then and not Day/Night system…


#16

It’s a summary.

Emphasis on possibly.
It only takes a minute to read the whole dialogue. Weather system doesn’t explain everything what I’m trying to accomplish, Day/Night system is the most appropriate in this manner. As I said before, its better to read the whole thread before replying- you can understand fully what I’m trying to do, therefore you can reply more accurately. I sense antagonism.

If you wish to carry this on, then feel free to message me.


#17

No antagonism and I did read the entire thread before answering. The fact of the matter is the title states Day/Night system and your opening line is literally

You then go on to state that you possibly want a weather system intertwined. But your main point was you wanted a day/night script. If you knew how to make a day and night script then why was it brought up at all?


#18

If you wish to carry on, message me.