I have a script where players touch a part with tools. I want to add a debounce so the player has to wait before giving it another tool. Can anyone help me with this?
oats = 0
print(oats)
local Allowed = false
function tch(h)
if (h.Parent.Oats.Name == "Oats") then
oats = oats + 1
h.Parent:Destroy()
print(oats)
end
end
script.Parent.Touched:connect(tch)
local Allowed = false
function give(dough)
if Allowed == true then
local y = dough.Backpack
local z = game.Lighting["Handful of Oats"]
z:Clone().Parent = y
oats = oats - 1
Allowed = false
end
end
function onClicked()
if oats > 0 then
Allowed = true
end
end
script.Parent.ClickDetector.MouseClick:connect(give)
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment
add a wait(1) on line 23