New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

My clock isn't functioning as intended, why?

Asked by 10 days ago

So I have a clock here, it uses Motor6Ds and all that to rotate the hands and stuff. But I've noticed that when the minute hand moves, it gradually gets slower, instead of it going fast at the start (moving every increment i believe.) and once it hits the next hour, it re-does this pattern. This also applies to the hour hand a bit, as it only moves a bit forward after some time, instead of it always moving. What is the problem here?

-- // Services
local LightingService = game:GetService("Lighting")
local RunService = game:GetService("RunService")

-- // Math
local Pi = math.pi
local Floor = math.floor
local Ceil = math.ceil

-- Some of these will be used later unless I actually need to.

-- // Instances
local hHand = script.Parent:WaitForChild("HourHand")
local hWeld = hHand.Hand.Motor6D
local mHand = script.Parent:WaitForChild("MinuteHand")
local mWeld = mHand.Hand.Motor6D
local globalHours
local globalMins

    1h = pi*2
    1h = 60m
    60m = pi*2
    1m = (pi*2)/60
    2m = ((pi*2)/60)*2
    60m = ((pi*2)/60)*60; pi*2

-- // Looping
while true do    
    globalMins = LightingService:GetMinutesAfterMidnight()
    globalHours = globalMins/60
    local Min = globalMins - (Floor(globalHours) * 60)
    if Min < 1 then mWeld.CurrentAngle = 0 end
    mWeld.DesiredAngle = ((Pi * 2)/60) * Min
    hWeld.DesiredAngle = ((Pi * 2) * globalHours/12) - (Pi * 2)
Motor6Ds might not be the best idea for this. Why not use HingeConstraints ( set to Servo? y3_th 130 — 10d
Well with hinge constraints it stops for no reason at some point due to collisions. kanchoplets 41 — 9d

Answer this question