Leaderstats and shop do not work when money value changed

This used to work, but now, the shop only works when you spawn in with enough money, but when you earn money a different way, or change the money value, it does not work, but does not give any errors.

The scripts are really simple, and used to work. In Server script service:

game.Players.PlayerAdded:connect(function(plr)

local folder = Instance.new("Folder", plr)

folder.Name = "leaderstats"

local cash = Instance.new("IntValue", folder)

cash.Name = "Rubble"

cash.Value = 100

end)

In the touch block:

local price = 20
local db = true

script.Parent.Touched:connect(function(hit)
if db == true then
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Rubble.Value >= price then
player.leaderstats.Rubble.Value = player.leaderstats.Rubble.Value - price
db = false
script.Parent.BrickColor = BrickColor.new(“Bright red”)
print(“Has enough”)

			wait(3)
			script.Parent.BrickColor = BrickColor.new("Bright green")
			db = true
		end
	end
end

end)

Did roblox change something? Thanks for the help.

1 Like

You’re updating your money in the client but the shop script is checking it in the server. You have to give the money through a server script or change the testing mode to server before editing the value manually.

1 Like