Ok now it works but it buys it automatically when i have 250 points instead of me having to click first
player=Game.Players.LocalPlayer --This creates a variable for the player
Points=player:WaitForChild("leaderstats"):WaitForChild("Cash") --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.Lighting.GravityCoil --This makes a vairable for the item being bought. Using ReplicatedStorage for storing things is better than Lighting tho.
function buy()--Creates a function to be called when the button's clicked.
if Points.Value >= 250 then --This checks if they have 250 points or more.
Points.Value = Points.Value - 250 --This subtracts from their points
upgradeStuff:clone().Parent = player.Backpack --This gives them the gravity coil
wait(2)--Waits a bit, not quite sure why this is here.
else --If they don't have enough points
script.Parent.Parent.Text = "You cant afford this!" --Tell them they can't afford it
wait(3)--Wait a bit
script.Parent.Parent.Text = "Gravity Coil" --Return the text to normal
end--Idk how to explain "end" to you. Check wiki.roblox.com for that one.
end
script.Parent.MouseButton1Down:connect(buy())--Don't forge
Its in a Local Script
How do i make it so you have to click buy first and you dont get it as soon as you can afford it?!

2 comments
No clue why it's not working properly, sorry
/\ Well then that comment was a complete waste of valuable time and energy.