Yes it is way better to use an event to change some value in a UI rather than polling all the time in a while loop if that is why you ask.
However there are situations where waiting on an event is hard to do (programatically) so you might opt for while loops. An example is when you want to check when a player walked far enough from an npc. This cannot be detected usually with events.
In your situation 100% try to do it with some event instead of while. Actually always try event and only if it doesn’t work go for while polling.
EDIT: Just to reply to @BasedKnowledge. That is even worse than doing wait(). Because Heartbeat:Wait() runs at every server step. This means that it runs by definition at least as frequent as wait() but sometimes it will run even more times. Thus, you waste even more processing in your idle wait loop.
Yielding means that the thread does NOT run anymore. In event based programming you want your threads to yield when there is not work to be done. You wake the threads up when there is an event only. In the case of Roblox if you set a listener with Connect(), that spawns a thread every time that event is triggered. So that is the best way to change the values in your UI.
Telling someone to not use wait and then telling them to use events but suggesting a replacement to wait is just bad practice with extra steps. You’re doing the same thing if not worse with Heartbeat:Wait().
Also @Sorbious that’s a weird way of phrasing it; I wouldn’t give that the right answer it’s more-so unneeded computations.