Updating Coins Inside of Shop GUI

So lets say you have a shop GUI, and your in a shop GUI. It shows your coins inside the shop but lets say you were then to get more coins whilst having the shop GUI open.

How would you script it so that an event fires whenever coins (inside a leaderstats or something) is updated, and then updating the coins value in the GUI Shop.

1 Like

gotta use Changed function or you can update it every few seconds because i dont like using Changed function as it doesnt update when player joins its just update when your coins value changes

1 Like

You could just make the update function a local function and call it when the player joins + when changed

e.g

local function update()
     — update shop label 
end

— player joined
update()
Cash.Changed:Connect(update)
1 Like

i prefer updating it ever few seconds anyways its up to you

here is a script i made for you

local function update()
     YourLabelHere.Text = "Cash:"..game.Player.LocalPlayer.leaderstats.CurrencyName.Value
end

— player joined
update()
Cash.Changed:Connect(update)
1 Like

Why? Doesn’t make any sense to me.

1 Like

well its just easy for me because updating every second script is much shorter

while wait() do
   YourLabelHere.Text = "Cash:"..game.Player.LocalPlayer.leaderstats.CurrencyName.Value
end

You literally just copied and pasted my script and added 1 more line, AND your code is messy.

Literal 2-3 line difference.

if you knew how to do then why did you ask in devforum? -_-

What did I ask for? I think you misread my replies buddy.

He was not the topic creator and these options are both equally good, only I prefer the one from @EmeraldLimes, because you don’t have to create an infinite loop, which is incredibly less lag for mobile players, for example.