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)