So I'm making a Tycoon game, and I really need help on this bug that I can't Solve:
When I touch a part, I want it to print my CURRENT amount of currency in my leaderstats for testing purposes. And of course I need this to check to see if the player has enough currency to but something in the tycoon
Problem:
When I touch the Part, It prints the correct amount of currency in my leaderstats that I set in this script inside the server script service:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = 'leaderstats'
local currency = Instance.new("IntValue", leaderstats)
currency.Name = 'Cash'
currency.Value = 150 -- it prints THIS ammount here
end)
But when I CHANGE my Currency Value to something different (inside the explorer tab and in my leaderstats) and touch the part AGAIN, it will still print the same value as it did before (150) No matter how many times I change it, it prints the same value over and over again.
Also, when I play the game again, I DON'T touch the part and change the currency value in my leaderstats, and then when I touch it, it will still print the same value I set in the script above.
Here is my script for when I touch the part:
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local playerLeaderstats = player:FindFirstChild('leaderstats')
if playerLeaderstats then
print(playerLeaderstats.Cash.Value)
end
end
end)
I thought this code will update every time I touch it but it doesn't
If you can suggest why it is not working or even a completely different method on how to do it, I will greatly appreciate it. This bug is delaying my development of my game, and again, if you know what is wrong or have a suggestion regarding a different message please let me know ASP.
Thanks for reading this

2 comments
You need to make sure the value is changed on the server, not the client.
Try changing the value using /console instead of explorer or by using admin commands.