This is my script so when you click a Gui Button and you have enough money, it clones a tool in Replicated storage and puts it in the player who bought it's backpack/inventory
player=game.Players.LocalPlayer --This creates a variable for the player
Points=player:WaitForChild("leaderstats"):WaitForChild("Points") --This makes a variable for their "Cash" value in leaderstats. If there isn't one, then this would cause an error. Giving us the output improves the likelyhood of us being able to give a good answer. I would replace this line with Points=player:WaitForChild("leaderstats"):WaitForChild("Cash")
upgradeStuff = game.ReplicatedStorage.GravityCoil --This makes a vairable for the item being bought. Using ReplicatedStorage for storing things is better than Lighting tho.
function buy()
if Points.Value >= 25 then --Cost
Points.Value = Points.Value - 25 --Cost
upgradeStuff:Clone().Parent = player.Backpack --This gives them the gravity coil
else --If they don't have enough points
script.Parent.Parent.Text = "You cant afford this!"
wait(3)--Wait a bit
script.Parent.Parent.Text = "Gravity Coil"
end
end
script.Parent.MouseButton1Down:connect(buy)
The problem is it doesnt put the Gravity coil in the inventory
