Having Trouble making a Selling System for my Simulator game

Hello,

I am trying to make a selling system for my simulator game.
However, whenever I step on the ‘sellingpart’ my ‘Clicks’ and ‘Money" change on the clients’ side but not on the server.

local part = game.Workspace.sellingpart
local db = false
part.Touched:Connect(function(hit)
local H = hit.Parent:FindFirstChild(“Humanoid”)
if H then
if not db then
db = true
local player = game:GetService(“Players”):GetPlayerFromCharacter(hit.Parent)
local leaderstats = player.leaderstats
local Clicks = leaderstats.Clicks.Value
local Money = leaderstats.Money.Value
print(Clicks)
Money = Money + Clicks
wait(0.5)
db = false
end
end

end)

Thanks.

You are changing only the “Money” variable inside your script, you are not changing the Value property

local moneyLeaderstat = Instance.new("IntValue")
moneyLeaderstat.Value = 300

local money = moneyLeaderstat.Value

print(money) --prints 300

money = money + 50 

print(money) --prints 350 as the variable changed
print(moneyLeaderstat.Value) --prints 300 as we only changed the variable and not the Property

moneyLeaderstat.Value += 100 --this is how you would properly change the money leaderstat

Now here’s a question, is this in a server script?

obvious it doesn’t server side.