How would I change this amount if it changes

Hello there,

I’m trying to create a UI that will change if the amount of “VibeBucks” changes. I’m not a very good scripter at all, so I used past formulas that seemed to work, but they don’t work here. (Honestly, I’m not surprised)

Anyways, here’s the script:

-- local script inside of a TextLabel

local p = script.Parent
local plr = game.Players.LocalPlayer
local vbs = plr.leaderstats2.VibeBucks

function updateVBSamount()
	p.Text = "$".. vbs.Value
end

vbs:GetPropetyChangedSignal("Value"):Connect(updateVBSamount)

I’m guessing it has something to do with the line

vbs:GetPropertyChangedSignal("Value"):Connect(updateVBSamount)

but I’m not sure.

I’m trying to access a secondary leaderstats folder (so it doesn’t show up on the in-game leaderboard). Inside of the folder is an “IntValue” which changes if the player gains a level or buys in-game cash. The thing about this is that it cannot detect when the value changes, and I’m not sure how it would. As I said before, I’m not very good at scripting and I haven’t been able to find anything that works in my case.

Any help would be greatly appreciated, thank you in advance!

Try this:

local p = script.Parent
local plr = game.Players.LocalPlayer
local vbs = plr.leaderstats2.VibeBucks

p.Text = "$" .. vbs.Value 
-- ^^ This is so that when a player joins the game or when they respawn, 
-- they will see their current amount of cash, instead of having to wait
-- until the cash value changes


vbs:GetPropertyChangedSignal("Value"):Connect(function() -- when the value changes
	p.Text = "$".. vbs.Value -- updates the text
end)
1 Like

You could try

vbs.Changed:Connect(function()
    p.Text = "$".. vbs.Value
end)