I’m not after real life time. As players would all have different timezones, so you’d only be able to play during the day time for the most part. I’m just using in game time and having it change over a period of time
I was just responding to @Wh7sk about there being a far easier way to do this for real life time. For you however, I’m aware you just wanted to do AM/PM.
Just subtract 12. Make sure you are storing the hour locally. Like in a new variable so you don’t end up setting the time to 2AM. Also only subtract 12 when the 24 hour clock is greater than 12 as in @Kymaraaa post.
Lighting:GetPropertyChangedSignal('ClockTime'):Connect(function()
local Hours = tonumber(string.sub(Lighting.TimeOfDay, 1, 2)) -- Gets the hours, turns 05 --> 5
local Minutes = string.sub(Lighting.TimeOfDay, 4, 5) -- Gets the minutes, keeps the extra 0
local String = '%s:%s %s'
if Lighting.ClockTime >= 13 and Lighting ~= 0 then -- It's between 1pm and 11:59pm
String = String:format(Hours - 12, Minutes, 'pm')
elseif Lighting.ClockTime >= 12 and Lighting.ClockTime < 13 then -- It's between 12pm and 12:59pm
String = String:format(Hours, Minutes, 'pm')
elseif Lighting.ClockTime >= 0 and Lighting.ClockTime < 1 then -- It's between 12:00am and 12:59am
String = String:format(12, Minutes, 'am')
else -- It's between 1:00am and 11:59 am
String = String:format(Hours, Minutes, 'am')
end
timer.Text = String
end)
Updated my post to address those issues you stated. The way you want midnight to display is strange, generally you’d want it to be 00:00, but it’s alright.