So I am trying to make script, that prints text on set time. I want it to print midnight on 00:00:00 of clock time and noon on 12:00:00. But for some reason, unknown for me, its not doing anything. Any idea what mistake am I doing.
function DayNightDoorCycle() while true do if game.Lighting:GetMinutesAfterMidnight() == 0 then print ("midnight") end if game.Lighting:GetMinutesAfterMidnight() == 720 then print ("noon") end end end
local function DayNightDoorCycle() while true do if math.floor(game.Lighting:GetMinutesAfterMidnight()) == 0 then print ("midnight") elseif math.floor(game.Lighting:GetMinutesAfterMidnight()) == 720 then print ("noon") wait() -- it stopped due to server exhuast execution end end end
Also, i reccomend using a function to check, like a getpropertychangedsignal or changed, as indefinite loops are't healthy. Also, you shopuld put a inf loop into a function, otherwise it will keep looping and the rest of the function lines won't run.
also, the values might constantly be changing in values, so i added math.floor()