Cash Gui not working

I am trying to show the moeny the play has on the gui, when I change it its there but then i have datastore and when i rejoin it doesnt change?

local player = game.Players.LocalPlayer --define player

local Money = player:WaitForChild("leaderstats"):WaitForChild("Data"):WaitForChild("Money") --define cash

Money.Changed:Connect(function() --whenever cash changes
	script.Parent.Text = "$ "..Money.Value --set text
end)

Any errors you get when you run the game?

What kind of script are you using?

Nope,

Here is some proof that its not working.
image

image

Local Script inside the textlabel.

Are you changing your money local-sided rather than server-sided? (in Studio there’s a way to toggle between the two modes.) If you’re doing this locally (on the client) it won’t replicate for the server to see, so therefor when DataStores goes to save your data, your money will be viewed as the previous value.

I did it like that it changed at the moment but when i rejoin it does not change.

local player = game.Players.LocalPlayer --define player

local Money = player.Leaderstats.Data:WaitForChild("Money") --define cash

Money.Changed:Connect(function() --whenever cash changes
	script.Parent.Text = "$ "..Money.Value --set text
end)

try that

Try initially setting the text as well:

local player = game.Players.LocalPlayer --define player

local Money = player:WaitForChild("leaderstats"):WaitForChild("Data"):WaitForChild("Money") --define cash

local function updateText()
    script.Parent.Text = "$"..Money.Value
end

Money.Changed:Connect(updateText)
updateText()
1 Like

Thank you so much this works and it works after I rejoin!

1 Like
local MoneyText = script.Parent.Text
local Players = game:GetService("Players")
local MoneyVal = Players.LocalPlayer.Leaderstats.Data:WaitForChild("Money")

wait(1)
MoneyText = "$ "..MoneyVal.Value --set text when it loads

MoneyVal.Value.Changed:Connect(function() --whenever cash changes
	MoneyText = "$ "..MoneyVal.Value --set text
end)