I created a shop GUI which opens and closes and I created a buy button for my tool but the thing is, it is supposed to give me the tool and take away my current money value (if my money reaches a minimum point, you would be allowed to buy it), it does not work, it does not give me the tool nor take away my money.
local Players = game.GetService("Players")
local SS = game:GetService("ServerStorage")
local stats = game.Players.player:WaitForChild("leaderstats")
script.Parent.MouseButton1Click.Connect(function(buy)
if stats.Cash.Value >= 150 then
stats.Cash.Value = stats.Cash.Value - 150
local Item = SS.Tools["Pistol"]:Clone()
Item.Parent = Players.player.Backpack
end
end)
What am I supposed to do? What did I do wrong?
EDIT: this script is a server script.

2 comments
Is this local or server script?
I said it was a server.