Changing leaderboard stats

Hello, I’m currently trying to make a farming game. I’m trying to make a sell system with proximity prompts using leaderstats, it works fine, however changing the intValue to a higher number than the set one doesnt seem to do anything? It just reverts back to it’s original value after selling.


local Players = game:GetService("Players")

local function leaderboardSetup(player)
	local leaderstats ="Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Money ="IntValue")
	Money.Name = "Money"
	Money.Value = 0
	Money.Parent = leaderstats
	local Wheat ="IntValue")
	Wheat.Name = "Wheat"
	Wheat.Value = 5
	Wheat.Parent = leaderstats



local Prompt = script.Parent

		local Money = Player.leaderstats.Money
		local Wheat = Player.leaderstats.Wheat
		if Wheat.Value >= 1 then
			Money.Value += 1
			Wheat.Value -= 1
		if Wheat.Value == 0 then

Any help is appreciated.

Are you adding currency on the client side?
That might be the issue

Wdym? Also for more context, changing the intValue works normally, however when the value gets subtracted it changes back to the original value. For example, changing the 5 ingame to something like 10 works fine, but subtracting it by 1 is 4. then 3 and so on.

Works fine outside of studio, no idea why this happens but that’s more important I guess