Well, its been a while since I scripted and now I'm rusty (not that I was any good before). I tried making a simple script that gives me an item in RepilcatedStorage when I press a TextButton. I successfully did it. I added a currency so I could deplete the points a character had if it decided to get a sword which cost 100 points. However, when I tried to tell the script to stop giving it to me once there was was already one in the backpack, it wouldn't work. I tried creating an if statement and I don't think I made it correctly. So here's the script I think will fix it. Did I do it right? Is there anything I can do to make my code cleaner?
Keep in mind the Item I'm cloning is in ReplicatedStorage and this local script is a child to the TextButton.
script.Parent.MouseButton1Click:connect(function()
local player = game.Players.LocalPlayer
local sword = game.ReplicatedStorage.ClassicSword
local points = player.leaderstats.Points.Value
local bought = false
if points.Value > 0 then
local newsword = sword:Clone()
newsword.Parent = player.Backpack
local bought = true
else
print("Already owned or insufficient funds")
bought = true
end
end)

2 comments
debounce?
doesn't the bought variable serve as a debounce already?