|
| 07 Oct 2016 11:39 AM |
| I need a script that can cycle through night and day, whilst adjusting the color of outdoor ambience to match. (IE: Dark purple at midnight, orange at sunrise, grey-ish midday, orange at sundown, and back to dark purple.) It should smoothly transition, and be easily editable so I can play around with the timescale. I know i made a post about this before, but people seemed to be confused with what I was asking for. (one guy just gave me a generic day/night script, got super angry when I told him that wasnt what I needed, someone else gave me a script to make pointlights become enabled at night, and a third person just told me how to tween color3's.) |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Oct 2016 11:45 AM |
--[[ PLEASE NOTE that I made this script BEFORE I knew about color lerping. My lighting looked like this: FogColor = 134, 149, 156 FogDistance = 1500 OutdoorAmbient = 255,255,255 Ambient = 50,50,50 Everything else 0,0,0 ]]--
l = game.Lighting mafterm = (10*60) daycolorR,daycolorG,daycolorB = 134/255,149/255,156/255 duskcolorR,duskcolorG,duskcolorB = 182/255,168/255, 131/255 steps = 45 interval = (.6)
function TransitionNight() for i = 1, steps do wait(interval) end end
while true do -- the tags local fogred = l.FogColor.r local foggreen = l.FogColor.g local fogblue = l.FogColor.b mafterm = mafterm+1 l:SetMinutesAfterMidnight(mafterm) -- the coroutines local TransitionDay = coroutine.wrap(function() game.ReplicatedStorage.Remote.DuskMusic:FireAllClients() for i= 1,steps do fogred= fogred +(duskcolorR/steps) foggreen= foggreen +(duskcolorG/steps) fogblue= fogblue +(duskcolorB/steps) l.FogColor = Color3.new(fogred,foggreen,fogblue) game.Lighting.FogEnd = l.FogEnd + 22 -- l.Brightness = l.Brightness+(1/steps) wait(interval) end game.ReplicatedStorage.Remote.AmbienceChange:FireAllClients("day") for i = 1,steps do game.Lighting.OutdoorAmbient = Color3.new(game.Lighting.OutdoorAmbient.r+(3/255),game.Lighting.OutdoorAmbient.g+(3/255), game.Lighting.OutdoorAmbient.b+(3/255)) fogred = fogred -((duskcolorR-daycolorR)/steps) foggreen = foggreen -((duskcolorG-daycolorG)/steps) fogblue = fogblue -((duskcolorB-daycolorB)/steps) l.FogColor = Color3.new(fogred,foggreen,fogblue) wait(interval) end end)
local TransitionNight = coroutine.wrap(function() for i = 1,steps do #################################################################################################################################################################### fogred = fogred -((daycolorR-duskcolorR)/steps) foggreen = foggreen -((daycolorG-duskcolorG)/steps) fogblue = fogblue -((daycolorB-duskcolorB)/steps) l.FogColor = Color3.new(fogred,foggreen,fogblue) wait(interval) end game.ReplicatedStorage.Remote.AmbienceChange:FireAllClients("night") for i= 1,steps do fogred= fogred -(duskcolorR/steps) foggreen= foggreen -(duskcolorG/steps) fogblue= fogblue -(duskcolorB/steps) l.FogColor = Color3.new(fogred,foggreen,fogblue) game.Lighting.FogEnd = l.FogEnd - 22 wait(interval) end end)
-- the time check if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then TransitionDay() interval = .6 elseif game.Lighting:GetMinutesAfterMidnight() == 17 * 60 then TransitionNight() interval = .275 end wait(interval) end |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Oct 2016 11:47 AM |
Sorry some pieces were censored Here is the link on paste bin: /zCfJ5WT1 |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2016 12:09 PM |
| Sadly, it seems your script does little more than advance the day cycle. It doesnt change fogcolor, ambient, outdoor ambient, or anything of the sorts. It does seem to fire servers stored in replicatedstorage. Maybe those parts are responsible for the change? |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Oct 2016 12:12 PM |
It actually does all of that.
This was directly lifted from my game Dusk, check it out to see how this effect should look for you. Make sure you have the Output open, and observe any errors that might be occurring.
|
|
|
| Report Abuse |
|
|
|
| 07 Oct 2016 12:19 PM |
| Okay, it would seem that now it DOES work, just that for some reason it didn't before. But this only tweens for 2 colors, 1 day color, and 1 night color, not the 4 color plan I had in mind. This does help me get an idea of what I'm working with though. Thank you. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Oct 2016 12:25 PM |
If it's truly working properly, it will adjust the day color, the night color, and the fog color between a deep orange, and black to give the illusion of dusk/dawn. I can't remember if I programmed purple in here or not.
But yes, learn color lerping, it's so much easier than this ^_^ less finicky |
|
|
| Report Abuse |
|
|