does anyone know why this happens or how i can fix it?
sped up the day night cycle so you can see
with a normal day night cycle the delay is much longer
does anyone know why this happens or how i can fix it?
sped up the day night cycle so you can see
with a normal day night cycle the delay is much longer
This is a roblox problem. One solution you could do is instead of using roblox’s nighttime, when it is about to turn nighttime switch your lighting to lower brightness, switch skybox, change sun image to a moon image, and adjust any lighting properties.
I made 2 functions which will translate normal Clocktime to where when it turns nighttime, the sun will instead follow where the moon would be:
-- Functions:
local function GetTimeInDay(Number) -- Translates clocktime so it stays daytime
return (Number >= 18 or Number <= 6) and Number + 12 or Number
end
local function GetClockTime(Number) -- Basically allows clocktime to go above 24 and will wrap it around. So 24 would stay 24, and 25 would become 1
local Max = 23.999
return Number > Max and Number - ((math.ceil(Number/Max) - 1) * Max) or Number
end
-- Code example:
local WantedRealClocktime = 3 -- This is the actual clocktime that we want, 3 am
local TranslatedClockTime = GetClockTime( GetTimeInDay(WantedRealClocktime) ) -- This is what we set the clocktime property as
Lets say it’s 3 in the morning. If you were doing a day and night cycle the normal way, it’d look like this:
Now if you put used my example code with 3, it outputs a clocktime in which the sun will be where the moon is:
(But you would have your fake day lighting effects applied)
I made an example script. Put this into a script in server script service and press run. Notice how there’s still a day/night cycle but the sun is always out:
local Lighting = game:GetService("Lighting")
local Speed = 0.05
local CurrentRealClockTime = 0
local function GetTimeInDay(Number)
return (Number >= 18 or Number <= 6) and Number + 12 or Number
end
local function GetClockTime(Number)
local Max = 23.999
return (Number > Max) and Number - ((math.ceil(Number/Max) - 1) * Max) or Number
end
while task.wait() do
-- Current real clocktime is what the clocktime would actually be, this can be used to decide if its night or not.
CurrentRealClockTime += Speed
if CurrentRealClockTime > 24 then -- This is needed
CurrentRealClockTime = 0
end
-- Find the "fake" clocktime and set it
local FakeClocktime = GetClockTime(GetTimeInDay(CurrentRealClockTime))
Lighting.ClockTime = FakeClocktime
end
I tried wording this the best possible, let me know if any of it doesn’t make sense. Also, this may seem like a lot of work but it allows a lot more control over how your nighttime looks and you can still use sunrays and make them look like moonrays, and gets right of the harsh transition from daylight to moonlight that you don’t like