Money Gui don't work in game

Hello, I made a money Gui (with tutorial) and it work when I test it on studio (see the screenshot). But after publishing in the real game, the money Gui don’t work anymore (see the second screenshot). Someone can help me to fix it please ?
Screenshot of studio in test :

Screenshot in real game :
The script (local script in textlabel):

1 Like
local Stats = game.Players.LocalPlayer.leaderstats:WaitForChild("Cash")

      script.Parent.Text = "Cash: "..Stats. Value

Avoid FindFirstChild

Because it may load even before the player is added

I tryed with your script but still don’t work (still do same thing).

Sorry about that

while wait() do
        local Stats = game.Players.LocalPlayer.leaderstats:WaitForChild("Cash")

        script.Parent.Text = "Cash: "..Stats. Value

Thanks, it work now, thank you so much two hours I m working on it :smiley:

This may work

while wait() do
local Stats = game.Players.LocalPlayer:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
script.Parent.Text = "Cash: "…Stats.Value

It is not necessary to use :GetPropertyChangedSignal for value objects, it only fires when the Value changes

Also using wait() is a bad habit for cases like these, try using the .Changed event instead.

        TextLabel.Text = newValue


@FerbZides’s solution will work, but the appropriate and efficient way to do this is to utilize the Changed event to avoid constantly looping unnecessarily.

Someone send me something similar who work too, thank anyway for helping :slight_smile:

I did not do this before

local Stats = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Cash")

      script.Parent.Text = "Cash: "..Stats. Value

This is efficient because it waits for the leadership and everything instead of just getting them all instantly

Ok, thank you for helping (Im very bad in script :sweat_smile:) Thanks

Still have issues what code u tried now?

The one I put in solution, work for me actually

it is still unnecessary, the .Changed event only fires when the value changes anyways.

@lllloooolllllm Here is a better alternative, efficient compared to using a while wait() loop

  local players = game:GetService("Players")
  local player = players.LocalPlayer
  local leaderstats = player:WaitForChild("leaderstats") 
  local cash = leaderstats:FindFirstChild("Cash")

       script.Parent.Text = "Cash: ".. newVal

Also try using :GetService() instead of using dot syntax for services.

edit: @FerbZides Then you probably did it wrong, try this

If the name of the value changes the script Breaks

That’s why I don’t use. Changed