How can I go about telling how many days have passed in game? Here is the code for the day-night cycle. Unsure if its needed, but here it is.
-- dayLength defines how long, in minutes, a day in your game is. Feel free to alter it.
local dayLength = 15
local cycleTime = dayLength*60
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
Also, If you’re looking for solution, I offer the next code snippet
local serverStart = os.clock()
local secondsElapsedSinceStart = 0
local daysSinceStart = 0
while task.wait(1) do
secondsElapsedSinceStart += 1
daysSinceStart = ((secondsElapsedSinceStart / 60) / 24)
-- Divides the seconds by 60 to get the minutes, and these minutes are
-- divided by 24, so the result would be the amount of days, you can use
-- math.round to get an integer.
end
I think that’s an option, but using maths to calculate the time passed since the start of the server and then dividing that by 60 seconds and then dividing again it by 24 would give the amount of days(in-game) passed.
Is this for real life days or in game days? Im looking for in game days if this is real life days. Sorry for the misunderstanding if it is real life days.
This is in the amount of time(in minutes) that you want, the 24 means 24 minutes so it will result the amount of in-game days as we divide the seconds by 60, so the result it’s the amount of minutes in there.