So a little more in depth... I am a beginner scripter and I am trying to make it so players can pickup an object from one point and they have to deliver it to another location for money. I have it figured out to where the destination takes away the object and gives money, but after the deliver it they can still stand on the destination brick and get money, is there any way I can make a cool down?
local debounce = false script.Parent.Touched:Connect(function(hit) if not debounce then debounce = true local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if plr then local holders = {plr:FindFirstChild("Backpack"), plr:FindFirstChild("StarterGear"), hit.Parent} plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 10 for i,v in pairs(holders) do pcall(function() for i,v in pairs(v:GetChildren()) do if v:IsA("BackpackItem") then v:Destroy() end end end) end end debounce = false end end)
You can just put a wait before you set the debounce to false
so it would look like
local debounce = false script.Parent.Touched:Connect(function(hit) if not debounce then debounce = true local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if plr then local holders = {plr:FindFirstChild("Backpack"), plr:FindFirstChild("StarterGear"), hit.Parent} plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 10 for i,v in pairs(holders) do pcall(function() for i,v in pairs(v:GetChildren()) do if v:IsA("BackpackItem") then v:Destroy() end end end) end end wait(60) debounce = false end end)