local script:
script.Parent.MouseButton1Click:Connect(function()
local cost = 10
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
if leaderstats then
local coins = leaderstats:WaitForChild("Coins")
if coins then
if coins.Value >= cost then
game.ReplicatedStorage:WaitForChild("Blue effect coins remove"):FireServer()
game.ReplicatedStorage:WaitForChild("Blue effect"):FireServer()
end
end
end
If I click fast then it will become -10 or -20 like that
script:
local BlueEffect = Instance.new("RemoteEvent", game.ReplicatedStorage)
local Blueeffectcoinsremove = Instance.new("RemoteEvent", game.ReplicatedStorage)
BlueEffect.Name = "Blue effect"
Blueeffectcoinsremove.Name = "Blue effect coins remove"
BlueEffect.OnServerEvent:Connect(function(plr)
local Sparkles = Instance.new("Sparkles", plr.Character.LowerTorso)
Sparkles.Name = "BlueEffect"
Sparkles.SparkleColor = Color3.new(0,0,255)
end)
Blueeffectcoinsremove.OnServerEvent:Connect(function(pl)
pl.leaderstats.Coins.Value = pl.leaderstats.Coins.Value - 10
end)

3 comments
Add a debounce, because when you click it the first time, the function is executing. The first event hasn't gone through all of it, so When you click it again. it thinks that you still have more than 9 coins: http://wiki.roblox.com/index.php?title=Debounce
^
Never rely on validation done on the client side. Check the cash on the server side before giving anything out.