Hi, i have encountered a problem where day & night cycle isnt working properly, it works but it doesn’t act smoothly, it works smoothly on baseplate and other maps but not this one, here’s the video (pay attention to the clock & sun)
is it based on clocktime changing? if so just update the UI based on the property change. I cant really tell the bug with the sun only the UI one
I just checked that Clocktime is going normal but the TimeOfDay flickers like the UI in the video, i think it has nothing to do with the ui, or the script since both of them work normally in the other maps, i deleted the ui and the results we’re the same so i’m thinking it has to do with the map itself? another note that the map is very old (3 or 4 years old), here’s the scripts if you want to take a look
day/night cycle:
local dayLength = 60
local cycleTime = dayLength*30
local minutesInADay = 24*60
local lighting = game:GetService("Lighting")
local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime
local timeRatio = minutesInADay / cycleTime
if dayLength == 0 then
dayLength = 1
end
repeat
local currentTime = tick()
if currentTime > endTime then
startTime = endTime
endTime = startTime + cycleTime
end
lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
wait(1/15)
until false
time ui:
L = game.Lighting
while true do
wait()
if (tonumber(string.sub(L.TimeOfDay,1,2))) == 12 then
script.Parent.Text = (tonumber(string.sub(L.TimeOfDay, 1, 2))) .. string.sub(L.TimeOfDay, 3, 5) .. " PM"
elseif (tonumber(string.sub(L.TimeOfDay,1,2))) == 00 then
script.Parent.Text = (tonumber(string.sub(L.TimeOfDay, 1, 2)) + 12) .. string.sub(L.TimeOfDay, 3, 5) .. " AM"
elseif (tonumber(string.sub(L.TimeOfDay,1,2))) > 12 then
script.Parent.Text = (tonumber(string.sub(L.TimeOfDay, 1, 2)) - 12) .. string.sub(L.TimeOfDay, 3, 5) .. " PM"
elseif (tonumber(string.sub(L.TimeOfDay,1,2))) < 12 then
script.Parent.Text = tonumber(string.sub(L.TimeOfDay, 1, 2)) .. string.sub(L.TimeOfDay, 3, 5) .." AM"
end
end
What’s the lighting technology (Lighting Properties) on the map that has the issue compared to the maps that it works fine on?
They are both ShadowMap, i changed that too while the game was running, but nothing changed
Do you have any other scripts in the problem game that may be trying to change the time of day?
Maybe disable the script you’re working with and see what happens to the time when testing.
it has so many scripts since it’s an open world project, is theres any way to find which script is doing this? (the map also was infested with viruses before i knew how to make my own models and stuff)
That could be your problem. Is the time changing when you disable your script?
You could use the search tool to look for TimeOfDay or GetMinutesAfterMidnight.
yeah you’re right it was my problem, i used the search tool and i found out i forgot to delete a script from a another clockgui that wasn’t working, now it works smoothly, thank you