How to change a value instead of minutes after midnight

So essentially I’d like this script to change a number value instead of setting minutes after midnight. I’ve tried for the life of me to do it. Is this doable, and if it is how would I go about doing this?

Quick note: Due to what I’m trying to do, I cannot just make the value the ClockTime, TimeOfDay, MinutesAfterMidnight, etc.

-- dayLength defines how long, in minutes, a day in your game is. Feel free to alter it.
local dayLength = 12

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

Resolved, I was overthinking it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.