To update texts is better to use Changed's or Loop's?

So how is it in the title what is the best way to update texts with Loop’s or Changed’s?

This problem is awfully ambiguous and no context is provided at all, but intuitively using .Changed should be better than a loop since a loop will run irrespective of their being any change. This means the script will redundantly repeat actions on already completed actions. However, the changed event will be fired only when a change is noticed, eliminating the problem with loops.

Though you haven’t asked for this, a method better than .Changed and loops is to use Instance:GetPropertyChangedSignal(property), using “Text” as the property you further reduce how many times the code runs without affecting the cases when it has to run. .Changed fires for properties such as parent and enabled and yada yada yada but GetPropertyChangedSignal will fire only for the property you request it to.


This post assumes you want to do something like autocorrect that needs constant updating on an input concerning object

2 Likes

Changed is better because looped is a constant repeat that probably causes lag in large amounts.

Changed events only fire when something was changed as the name suggests. Things like text have no reason to be updated on a loop unless you need to update something constantly at a certain rate. Things like custom chat effects often require something like this, however this is often doing more than just updating the text property.

For example if you are updating a players cash every 60 seconds, there would really be no reason to use a loop in this case as the loop would constantly be running vs. a Changed event which would only run upon the cash being updated.

Visually there would be no difference to players and in only extreme cases would you have performance hits but for the sake of good coding practices and clean organized code a Changed event should be your go-to. Hopefully this answered the question, the title was a little hard to understand.