Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing The Text Label As The Leaderboard's Value Changes?

Asked by 3 years ago

I want that when the player buys a thing and his money get deducted at the time it gets deducted I want the text label to show his money as it get deducted but my script dosent it keeps the value as it was the first time the player joined it dosent work can someone help me?

local Money = script.Parent.Menu.Money
local plr = game.Players.LocalPlayer
local Gold = plr.leaderstats.Gold.Value
Gold.Changed:Connect(function()
    Money.Text = "Gold: "..Gold
end)
0
What you're doing wrong is your [[Gold]] variable. You are actually saving the current Value of Gold. You should instead set the variable to the path to your Gold. Then when you use your variable you write Gold.Value Spjureeedd 385 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

You can use the GetPropertyChangedSygnal() function for it. Here you go:

local Money = script.Parent.Menu.Money
local plr = game.Players.LocalPlayer
local Gold = plr.leaderstats.Gold
Gold:GetPropertyChangedSygnal("Value"):Connect(function()
    Money.Text = "Gold: "..tostring(Gold.Value)
end)
0
This is a solution, a good one, but you should also announce the asker to what they did wrong. Spjureeedd 385 — 3y
0
thx kidsteve923 139 — 3y
Ad

Answer this question