Hello!
3 days ago I made a script that checks if the player’s money number is changing. If so, GUI will show its value.
Local script
plr = game.Players.LocalPlayer
script.Parent.MoneyBox.Text = plr.Leaderstats.Money.Value
plr.Leaderstats.Money.Value:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.MoneyBox.Text = plr.Leaderstats.Money.Value
end)
Players.KotyOceloty.PlayerGui.MoneyGUI.PlayerCashFrame.LocalScript:5: attempt to index number with ‘GetPropertyChangedSignal’
unfortunately, the following message is displayed on the output.
Tried setting the player’s money amount to a variable but that didn’t work.
What should I do?
drilinz
(drilinz)
June 12, 2022, 1:24pm
#2
Change it to:
plr = game.Players.LocalPlayer
script.Parent.MoneyBox.Text = plr.Leaderstats.Money.Value
plr.Leaderstats.Money:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.MoneyBox.Text = plr.Leaderstats.Money.Value
end)
You wrote “Money.Value ” instead of just “Money:GetPropertyChangedSignal()”
Forummer
(Forummer)
June 12, 2022, 5:58pm
#3
For ValueObjects you should be using their ‘Changed’ signal instead, the added benefit is that the ValueObject’s new value is automatically passed as an argument to any connected callback function.
plr.Leaderstats.Money.Changed:Connect(function(v)
script.Parent.MoneyBox.Text = v
end)