Advertisement
HowToRoblox

ClockHandler

Apr 13th, 2020
1,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local secsHand = script.Parent.SecondsHand
  2.  
  3. local minsHand = script.Parent.MinutesHand
  4.  
  5. local hoursHand = script.Parent.HoursHand
  6.  
  7.  
  8. local centre = script.Parent.Centre        
  9.      
  10.      
  11.  
  12. while wait() do
  13.    
  14.    
  15.     local t = tick()
  16.    
  17.    
  18.     local secs = math.floor(t % 60)
  19.            
  20.     local mins = math.floor((t / 60)% 60)
  21.            
  22.     local hours = math.floor((t / 3600)% 24)
  23.    
  24.    
  25.     local secsAngle = -(secs * 6)
  26.    
  27.     local minsAngle = -(mins * 6)
  28.    
  29.     local hoursAngle = -(hours * 30)
  30.  
  31.  
  32.     secsHand.CFrame = CFrame.new(centre.Position) * CFrame.Angles(math.rad(secsAngle), 0, 0) * CFrame.new(0, secsHand.Size.Y / 2, 0)
  33.    
  34.     minsHand.CFrame = CFrame.new(centre.Position) * CFrame.Angles(math.rad(minsAngle), 0, 0) * CFrame.new(0, minsHand.Size.Y / 2, 0)
  35.    
  36.     hoursHand.CFrame = CFrame.new(centre.Position) * CFrame.Angles(math.rad(hoursAngle), 0, 0) * CFrame.new(0, hoursHand.Size.Y / 2, 0)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement