Int Value acting weird

Sorry for the bad title but i have no idea how to title this.

So I am making this simulator type game test that has points, multipliers and cash with datastore.

So there is this tool that when you click it it gives you plus 1 points times the multiplier, to buy multipliers you click a gui, it will check to see if you have enough cash(which is 10) and if you do it will minus the amount of cash that you paid for and you will get plus 1 multiplier.

The problem is that i have this part for testing purposes that when you click it it gives you plus 1 cash but if you press it after you buy a multiplier it gives you plus 10 cash and then plus 1 like it is supposed to:

This is the cash giving script:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
end)

This is the Multiplier scipt:

Multiplus.MouseButton1Click:Connect(function()
	if player.leaderstats.Cash.Value >= 10 then
		game.ReplicatedStorage.Multiplus:FireServer()
		player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 10 -- for some reason when i press plus 1 cash button it also adds this amount that I minus.
	else 
		print("You're poor lol")
	end
end)

I don’t know why when you click plus 1 cash it also adds the amount that i minus from the player

The problem is that changing an IntValue on the client won’t replicate on the server. The client will register the -10 change, but when Cash is altered again on the server, the server still thinks Cash is at it’s original value, so the client appears to be gaining 11 from that one click.

You can only change leaderstats on the server, and for security reasons you should also put the conditions on the server as well (checking if Cash.Value > 10) as exploiters could send your Multiplus remote without passing the condition.

Ohhhhh, i see, thanks for the help!

1 Like

Incorrect, you can change almost anything client-side that you can server-side, just the same case of replication as you explained in the first paragraph.