GetPropertyChangedSignal Value changes?

Hi there,

I’ve got this script that is meant to update Text when the Value of coins is updated it’s working but its using the old Value of “currentcoins” when i need it to get the latest Value and display the change of the Values

Script:

local player = game.Players.LocalPlayer

local coinstat = player:WaitForChild(“coinstats”)

local coins = coinstat:WaitForChild(“Coins”)

local text = script.Parent.Amount

local function currentCoins()

local newCoins = coins.Value - currentcoins

text.Visible = true

text.Text = "+: "…newCoins

wait(2)

text.Visible = false

end

coins:GetPropertyChangedSignal(“Value”):Connect(currentCoins)

currentcoins = coins.Value

Thanks,

Your issue is you forgot to add currentCoins to function

local function currentCoins(currentcoins)

Yeah, thats incorrect:

That’s why I deleted it before you said this because I didn’t look at it correctly, the script isn’t formatted which makes it harder to read :man_shrugging:

Eh i get this error? attempt to perform arithmetic (sub) on number and nil

Try reading this, this may have your answer Attempt to perform arithmetic (sub) on number and nil?

1 Like

Why do you do this? currentcoins should already be the new value.