Advertisement
AndiGodGamersDev

Update CountDown

Aug 16th, 2023 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | Source Code | 0 0
  1. local TargetDate = os.time({year=2023, month=8, day=28, hour=14, min=0, sec=0})
  2.  
  3. function ConvertToDHMS(Days,Hours,Minutes,Seconds)
  4. return string.format("%dd %02dh %02dm %02ds", Days, Hours, Minutes, Seconds)
  5. end
  6.  
  7. function UpdateCountdownDisplay()
  8. -- Change: 5 to whatever your timezone is (EG. New York = - 5)
  9. local Time = os.date("!*t", os.time() - 5* 60 * 60)
  10. local CurrentDate = os.time(Time)
  11. local SecondsLeft = TargetDate - CurrentDate
  12. local days = math.floor(SecondsLeft / (24 * 60 * 60))
  13. local hours = math.floor((SecondsLeft % (24 * 60 * 60)) / (60 * 60))
  14. local minutes = math.floor((SecondsLeft % (60 * 60)) / 60)
  15. local seconds = math.floor(SecondsLeft % 60)
  16.  
  17. game.Workspace.CountdownPart.SurfaceGui.CountdownText.Text = ConvertToDHMS(days, hours, minutes, seconds)
  18. end
  19.  
  20. while true do
  21. UpdateCountdownDisplay()
  22. wait(1)
  23. end
Tags: lua
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement