✓ Accepted answer
You have the right idea, the only issue with this is that you are changing the value of your money inside a local script. The reason why this doesn't work is due to Filtering Enabled. This property prevents exploiters from altering world properties server-wide, thus, in order to change your money value, you would have to change it from a server script. I see you have a remote event fired to the server with "tool.Value", I'm assuming this is to replicate the tool inside the player backpack!
From that local script, remove the eighth line and fire the server with two values, the tool.Value and the price. That way, these values can be picked up from the server script and be manipulated server-wide.
Here's what the local script should look like now:
local price = script.Parent.Parent.Price
local tool = script.Parent.Parent.ItemName
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
local ls = players:FindFirstChild("leaderstats")
if ls and ls.LCoins.Value >= price.VAlue then
game.ReplicatedStorage.ShopBuy:FireServer(tool.Value, price.Value)
end
end)
So, this sends the server the tool Value and the price of the tool. Now all we have to do is Replicate the tool into the backpack and change the cash values!
In the Server Script, you should have something similar to this:
local tools = game.ReplicatedStorage:WaitForChild("Tools")
game.ReplicatedStorage.ShopBuy.OnServerEvent:connect(function(plr, toolValue, price)
local ls = plr:FindFirstChild("leaderstats")
if ls then
ls.LCoins.Value = ls.LCoins.Value - price
end
end)
So you input your tool-giving code in there, and while doing that, removing the price Value from the money value!
I hope this helps! LMK if you have any questions :)