Currency change gui not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    To see how much the currency have changed
  2. What is the issue? Include screenshots / videos if possible!
    Instead of how many coins I got, it prints on how many coins I have
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I don’t know what’s going on and I don’t know how to fix it cause I don’t know how to get the changed number
-- game.Players.PlayerAdded:Connect(function(player)
	local Money = player:WaitForChild("leaderstats").Coins
	local Amount = Money.Value

	Money:GetPropertyChangedSignal("Value"):Connect(function()		
		if Money.Value > Amount then
			local Increment = (Money.Value - Amount) --Amount of money you receive
			print(Increment)
		end
	end)
	Amount = Money.Value
end)

Is this a local or serverscript-

Secondly, if you want to change the currency, I suggest creating a remote event for this.

local Remote = game.ReplicatedStorage.Event

Remote.OnServerEvent:Connect(function(player)
       	local Money = player:WaitForChild("leaderstats").Coins
	local Amount = Money.Value
        
       if Money.Value >= Amount then
         local Increment = (Money.Value - Amount) --Amount of money you receive
       print(Increment)
       end
end)

or, you can do your old script.

game.Players.PlayerAdded:Connect(function(player)
	local Money = player:WaitForChild("leaderstats").Coins
	local Amount = Money.Value

	Money:GetPropertyChangedSignal("Value"):Connect(function()		
		if Money.Value >= Amount then
			local Increment = (Money.Value - Amount) --Amount of money you receive
			print(Increment)
		end
	end)
	Amount = Money.Value
end)

You used the wrong syntax, haha.

How would you know, did you even try it?

Secondly, if you don’t think my solution for it would work, make your own.
(No offense)

I’m unaware if it’s a server or local script, secondly you cannot change values from a local script and except them to change, that’s for the server hence why I said make it a remote event.

  • We do not know what the script is doing it for, so we are unaware what to do with it.

I know you can’t, you are changing the text on the UI

It never said that, as it seems the script is a server-script. Which would mean your code is wrong, you cannot change values through local scripts, as his original code says:

-- game.Players.PlayerAdded:Connect(function(player)
	local Money = player:WaitForChild("leaderstats").Coins
	local Amount = Money.Value

	Money:GetPropertyChangedSignal("Value"):Connect(function()		
		if Money.Value > Amount then
			local Increment = (Money.Value - Amount) --Amount of money you receive
			print(Increment)
		end
	end)
	Amount = Money.Value
end)

It appears that is a server-script and that some syntax errors are infact there.

oh I misread the question nvm oof

what is syntax errors? and where is it?

1 Like

You shouldn’t put the :GetPropetyChangedSignal() function in the game.Players.PlayerAdded function. Instead, just put it outside of the functions Ex.

local plr

game.Players.PlayerAdded:Connect(function(player)
        plr = player
end)

local leaderstats = plr:WaitForChild("leaderstats")
local Money = leaderstats:FindFirstChild("Money")

Money:GetPropertyChangedSignal("Value"):Connect(function()
       -- Your code here
end)

The problem is Theres a bug where if currency got increased or decreased,it shows how many times i increased in the print, like for example, player.leaderstats.money.value + 10 then it shows 1 and if I run it again, it shows 2 instead of 10 and I know it’s at line 7 where the local increment are.

Try in Print() the getProperty changed and if it don’t print then maybe you edit from the player view while play testing

I already done that at the very beginning print(Increment), it only runs when the currency have been changed so nil

So then,Did you just hop in explorer after press play and edit your value? without changing to server mode

Syntax means code.
Error means incorrect functionality