[Closed]Monetary system error, when receiving money, you also receive the money spent

  1. What do you want to achieve?
    I want that when killing does not return the money spent

  2. What is the issue? https://gyazo.com/cac5e50a5624631cf945d681a024c7f3 It is assumed that when I kill I receive 5 money but it returns the money spent

  3. What solutions have you tried so far?
    I tried modifying the stats of the leaders, but I think the problem is with the store itself

-- local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = script.Parent.Parent.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:connect(function()
	if player.leaderstats:FindFirstChild("Cash").Value >= price.Value then 
		player.leaderstats:FindFirstChild("Cash").Value = player.leaderstats:FindFirstChild("Cash").Value - price.Value
		game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
	end
end)

or maybe it’s the kill for money system?

player should be
local Player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()

1 Like

Is the script a local script? Im assuming so via the “fireserver”. In this case, you are trying to change values locally, meaning it does not match the server and there lies your problem.

Try moving this:
player.leaderstats:FindFirstChild(“Cash”).Value = player.leaderstats:FindFirstChild(“Cash”).Value - price.Value

into your “buy” remote. Also make sure the player is defined in the remote (although im certain its already defined via where it’s fired from)

1 Like

You shouldn’t have to subtract the money on the client. You could just call ShopBuy:FireServer(tool.Value) and do all the checks on the server.

1 Like