I am wanting a rotation to be applied to a UI, based on time of day. It should continuously rotate (not just automatically lock every 6 hours), I just provided like a general guide as to what rotation it should be at basted on each time of day
local function UpdateTime()
-- Set Rotator
Rotator.Rotation = 0
--[[
Rotation = Lighting.ClockTime
0 = 12
90 = 18
180 = 0
270 = 6
--]]
end
Just make the tween info adjust for the current time.
For example:
local CurrentTime = os.time() --// Or the way you get the current time
local Midnight = whenitsmidnight
local Info = TweenInfo.new(Midnight - Currentime)
I still feel this could get out of sync overtime. As the server updates the clocks time. I want something that’s gonna be consistent with the clocks time, not just a tween
local DAY_LENGTH = 24*60*60 -- divide by two for same rotation for day and night
local function getDayPercent()
local time = os.time()
return (time % DAY_LENGTH) / DAY_LENGTH
end
local frame -- TODO: Set to the frame you want to rotate
local ROTATION_OFFSET = 0 -- offset from upwards (basically if you want your clock to start from the side or something)
local function updateUI()
frame.Rotation = 360 * getDayPercent()
end
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function() -- can also use heartbeat or wait loop etc.
updateUI()
end)
Edit:
Oh you’re using clock time. I assume you update clock time based on a float not an int right?
Change the getDayPercent to:
local DAY_LENGTH = 12
local Lighting = game:GetService("Lighting")
local function getDayPercent()
local time = Lighting.ClockTime
return (time % DAY_LENGTH) / DAY_LENGTH
end