See, I'm trying to make a time gui with a 12 hour loop. I'm using a textlabel for this and already have a day and night script. I've tried a bunch of different scripts. I feel like this would work, but obviously nothing is.. This is what I have so far.
while true do script.Parent.Text = string.sub(game.Lighting.TimeOfDay,1,5) wait() if Lighting.TimeOfDay >= 13 then script.Parent.Text = Lighting.TimeOfDay - 12 elseif Lighting.TimeOfDay <= 12 then script.Parent.Text = string.sub(game.Lighting.TimeOfDay,1,5) wait() end
Help would very much be appreciated
Your script was erroring because TimeOfDay was a string and you were comparing it to a number. You either compare the numbers to ClockTime, (or TimeOfDay if you converted it to a number like steamg0d said.)
Also, you need to change the time which idk if you're doing somewhere else but added it here.
changeTimeIncrement = .1-- how often you want to change the in game clock time in seconds while wait(changeTimeIncrement) do --update time local hoursPassed = 0 local minutesPassed = 10 game.Lighting.ClockTime = game.Lighting.ClockTime + hoursPassed + (minutesPassed / 60) --convert to 12 hr format if game.Lighting.ClockTime >= 13 then local hour = math.floor(game.Lighting.ClockTime) local minutes = math.floor((game.Lighting.ClockTime-hour)*60 + 0.5) local timeString = nil if(minutes >= 10)then timeString = hour - 12 .. ":" .. minutes else timeString = hour - 12 .. ":" .. minutes .. "0" end script.Parent.Text = timeString elseif game.Lighting.ClockTime <= 12 then if(game.Lighting.ClockTime < 10)then script.Parent.Text = (string.sub(game.Lighting.TimeOfDay,2,5)) else script.Parent.Text = (string.sub(game.Lighting.TimeOfDay,1,5)) end end end