I made a script about a Gui Tool shop. (I'm making a game inspired / based off of Old School Runescape. I made a shop gui to buy a axe. When you buy the "Cash" From the leaderboard goes down by 10. (I made the leaderboard with 15 "Cash". When you buy it you can spam click it to buy how many axe you want for free! It seems that when you only have "Cash > 10 it will minus ten. But when you don't you get it for free (Sorry for the lack of grammar)
---Sever Script---
local Event = game.ReplicatedStorage.RemoteEvent
Event.OnServerEvent:Connect(function(player, toolName) local clonedTool = game.ReplicatedStorage:FindFirstChild("Axe"):Clone() clonedTool.Parent = player.Backpack end)
local Event = game.ReplicatedStorage.RemoteEvent
Event.OnServerEvent:Connect(function(player, toolName) if player.leaderstats.Cash.Value >= 10 then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 10
local clonedTool = game.ReplicatedStorage:FindFirstChild():Clone()
clonedTool.Parent = player.Backpack
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value -10
end
end)
Really hope you can help.
---Local Script---
local Event = game.ReplicatedStorage.RemoteEvent local toolName = "Axe"
script.Parent.MouseButton1Click:Connect(function() -- when player clicks the button Event:FireServer(toolName) end)

1 comment
please format your entire script