You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
To see how much the currency have changed
What is the issue? Include screenshots / videos if possible!
Instead of how many coins I got, it prints on how many coins I have
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)
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)
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.
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.
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.