Why wont my Money Gui work?

So… this is my leaderstats/datasave script… works 100%

local dss = game:GetService(“DataStoreService”)

local DataStoreToKeep = dss:GetDataStore(“Chipotle”)

game.Players.PlayerAdded:Connect(function(player)
local is = Instance.new(“Folder”,player)
is.Name = “leaderstats”

local money = Instance.new(“IntValue”,is)
money.Name = “Money”
money.Value = 0

local cc = Instance.new(“IntValue”)
cc.Parent = player
cc.Name = “CashCollected”

local robbing = Instance.new(“BoolValue”,player)
robbing.Name = “Robbing”
robbing.Value = false

player.CharacterAdded:Connect(function(char)
player.Robbing.Value = false
player.CashCollected.Value = 0
end)

local data
local success, errormessage = pcall(function()
data = DataStoreToKeep:GetAsync(player.UserId… “-money”)
end)
if success then
money.Value = data
else
warn(errormessage)
end
end)

game.Players.PlayerRemoving:Connect(function(player)

local success, errormessage = pcall(function()
DataStoreToKeep:SetAsync(player.UserId…"-money",player.leaderstats.Money.Value)
end)
if success then
else
warn(errormessage)
end
end)

game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
DataStoreToKeep:SetAsync(player.UserId…"~money", player.leaderstats.Money.Value)
end
end)

But I have a Gui

I want it to show the money… so I scripted this inside of the text label… its a local script

local text_label = script.Parent
local plr = game.Players.LocalPlayer

plr:WaitForChild(“leaderstats”).Height.Changed:Connect(function(val)
text_label.Text = "Height: "…val
end)

text_label.Text = "Height: "…plr:WaitForChild(“leaderstats”).Height.Value

but when I test it doesnt work… Can someone tell me what I did wrong or rewrite the local script or me please…

1 Like

In the script you provided, I don’t see an IntValue named Height in the player’s leaderstats.

I think you want to use the IntValue called Money.

Any errors popped up in the output from your local script? Does the text not change at all?

1 Like

I just did what the person above told me and this happened


idk whats wrong…

1 Like

and yeah, the text doesnt change at all

1 Like

Try using this code for your LocalScript:

local TextLabel = script.Parent
local plr = game.Players.LocalPlayer

local leaderstats = plr:WaitForChild("leaderstats")
local HeightValue = leaderstats.Height

TextLabel.Text = "Money: " ..HeightValue.Value

HeightValue:GetPropertyChangedSignal("Value"):Connect(function()
   TextLabel.Text = "Money: " ..HeightValue.Value
end)

Edit: found a small mistake, just fixed it

didnt work…

Show an image of your current script

1 Like

I dont see a problem at all. However, in your previous image, i see that all your UI is disabled. Is the specific UI enabled? And just to confirm, no errors were given in the output, correct?

no

1 Like
local plr = game.Players.LocalPlayer

local leaderstats = plr:WaitForChild("leaderstats")
local HeightValue = leaderstats.Height

TextLabel.Text = "Money: " ..HeightValue.Value

HeightValue.Changed:Connect(function(new_val)
   TextLabel.Text = "Money: " .. new_val
end)

You don’t have to do GetPropertyChangedSignal. Use a changed event.

local TextLabel = script.Parent
local plr = game.Players.LocalPlayer

local leaderstats = plr:WaitForChild("leaderstats")
local HeightValue = leaderstats.Height

TextLabel.Text = "Money: " ..HeightValue.Value
print("done")
HeightValue:GetPropertyChangedSignal("Value"):Connect(function()
print("done2")
   TextLabel.Text = "Money: " ..HeightValue.Value
print("done3")
end)

show us the output

1 Like

This should work:

local player = game.Players.LocalPlayer

script.Parent.Text = "Denarii: "..player.leaderstats.Denarii.Value

I used this in one of my games and it works perfectly. Of course you would change denarii to the name of your currency and the script is a local script inside of the text label.

1 Like

Its saying that Height either is misspelled or does not exist at all in the leaderstats folder. Are you sure you have spelled Height value correctly?

1 Like

1st. you never name your textlabel variable
2nd try leaderstats:WaitForChild(“Height”)
3rd wheres the printing

1 Like

This worked perfectly, but is there a way that it doesnt have to say money in the front?

Yep you can just put:

local player = game.Players.LocalPlayer

script.Parent.Text = player.leaderstats.Denarii.Value
1 Like

Wait were you trying to have the Money value display on the text???

1 Like