I'm trying to make a cash-per-second feature to a leaderstat, yet whenever I modify the cash, it goes back to it's orginal state. This is what I have:

game.Players.PlayerAdded:Connect(function(player)
	wait(5)
	while true do
		player.coinsfolder.Coins.Value = player.coinsfolder.Coins.Value + 3
		wait(3)
	end
end)

I also have a shop, this is a script that deduces cash:

script.Parent.MouseButton1Click:connect(function()

 local price = 3 
 local player = game.Players.LocalPlayer
 local stats = player:WaitForChild("coinsfolder")
 
 if stats.Coins.Value >= price then
  stats.Coins.Value = stats.Coins.Value - price
player.blocksfolder.blocks.Value = player.blocksfolder.blocks.Value + 1
 end
end)

let's say that I have this many coins

I buy the blocks, so I have this many coins now

Then, it should be 16 coins, right? because 13 plus 3 is 16? the cash per minute adds 3 to my coins.

Though, the cash-per-minute script instead ignores that the shop takes away 3, and it still thinks I have 16 coins instead of 13 that I have. So it jumps from 13 all the way to 19 instead, see?? I think the problem is in the coins per second script. It will be a great help if you give me a hand.

3 comments

0

Try other numbers, I believe there is a problem there.

0

Doesn't work. Set it to 1 cash per 1 second, 10 cash per 10 seconds.

0

The cash-per-minute feature is controlled via the Server, whilst the cash deduction is performed locally. This change isn't permitted by FilteringEnabled, therefore the modification isn't noticed on the global representation of the user's cash; the Server rejects a local change, therefore will not update the cash—resulting in it reading 16 instead of 13.