Mirroring Personal Money GUI to my Leaderboard Money Value?

I have a money intvalue for my leaderboard and I also want a gui in the bottom right of my screen to always equal my personal money on the leaderboard.

Should I use a wait() loop? I keep hearing while wait() do loops are bad practice if they go on infinitely, so I was also thinking of using renderstepped (if that’s possible) but if there’s a better, more efficient way, I need that solution.

Please feel free to share your thoughts.

Can’t you use the Changed event in that case if you want the gui on the bottom right to equal the amount of money you have in your leaderboard?

Money.Changed:Connect(function(value)
    TextLabel.Text = "$" .. value
end)

Where Money is the variable containing the IntValue and TextLabel being the TextLabel that should be equal to your money

(Just a reminder that the changed event only works like this for ValueBases, such as IntValues, StringValues, etc. It works differently for other instances)

I agree with this: if there’s an event-based solution that exists, always opt to use that instead of a loop. A pointer of advice though: always try to accommodate for initial/existing items. Most use cases involving changing data should be hit with initial state.

You can do this by defining the function to connect to changed in a local variable. Connect it to Changed and then call it for the first time, manually passing your value.

local function moneyChanged(value)
    TextLabel.Text = "$" .. tostring(value)
end

Money.Changed:Connect(moneyChanged)
moneyChanged(Money.Value)

yeah, i just didn’t know the .Changed event was a thing

yeah you’re right, I just didn’t know that the .Changed event existed