How to rotate something based on ClockTime

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

What you could do I assume is do if statements for the Lighting.ClockTime and set your Rotator.Rotation to your provided time.

Please reply if you don’t understand or if I’m incorrect on what I’m trying to say.

Can’t you just tween the clock to move a full rotation every day?

Not a great idea. As I said, I don’t want it to snap. So I’d have to literally do 24 if statements

if ClockTime == 0 then
-- 180
elseif ClockTime == 1 then

elseif ClockTime == 2 then

elseif ClockTime == 3 then

-- etc. all the way to 23

Problem is when you join, the time of day may be different. SO if you join at midnight, it can’t start at 0, as 0 is midday

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 = - 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

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()

local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function() -- can also use heartbeat or wait loop etc.

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

You can use rule of 3

local Lighting, Day = game:GetService("Lighting"), 24
	local ClockTime = Lighting.ClockTime
	script.Parent.Rotation = (ClockTime * 360)/Day

24 is how many hours a day equals and it can be another number, it would also work with os.time, only ClockTime is replaced by the current hours.

local lighting = game:GetService("Lighting")
local ui = script.Parent

local function getDegree()
	local fraction = lighting.ClockTime/24
	local degree = ((fraction * 2 + 1) * 180) % 360
	return degree

ui.Rotation = getDegree()
	ui.Rotation = getDegree()