I am currently making a duty free shop. Its just you click an item and it appears in your inventory. To prevent spamming, I want it so you can only get one of the items. I know you have to use debounce, I just don’t know how to incorporate it into my script. Thanks for reading.
Script:
local ToolNames = {"Sleeping Set"}
local Storage = game:GetService("ServerStorage")
local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(Player)
if Player and Player.Character then
local Backpack = Player:WaitForChild("Backpack")
for i = 1, #ToolNames do
local Tool = Storage:FindFirstChild(ToolNames[i])
if Tool then
Tool:clone().Parent = Backpack
end
end
end
end)