If I have a script that needs to run forever, should I be using while task.wait() do?

I have a daily rotating shop system and it needs to be actively checking if the day has changed.

while task.wait(5) do
	if CurrentDay ~= os.date("%j") then
		--update shop stuff
	end
end

Is there a better way to do this? I don’t think calling os.date has any performance issues, even so it’s every 5 seconds so it can’t be horrible. Is there a connection I can use that tells me when the day has changed IRL or should I be just fine with a never ending loop(I’ve heard bad things about them)?

Seems ok, if you check your script activity it will probably be less than 0.1% it should be fine and there are bigger fish to fry.

Otherwise for script improvement ideas, perhaps try a more event based approach detect the time during player join, every time the main menu opens.

If you need a notification without needing player input perhaps a long wait? Not sure about the performance implications but it doesn’t show up on script activity which should be the main concern. Might be false IDK

print("Hello world!")

task.wait(5*60*60)

print("5 hours have passed")