I have a debounce that should make it take 5 seconds to use this hopperbin again. However, it doesn't work! It works a little, but not for 5 seconds. Please help.
local tool = script.Parent local plr = tool.Parent.Parent local db = false tool.Selected:connect(function(mouse) mouse.Button1Down:connect(function() if db == false then db = true local target = mouse.Target print(target) if game.Players:GetPlayerFromCharacter(target.Parent) then if (target.Parent.Torso.Position - plr.Character.Torso.Position).magnitude <= 7 then target.Parent.Torso.Velocity = plr.Character.Torso.CFrame.lookVector * 150 end end end wait(5) db = false end) end)
The problem is that you added the wait and db= false onto the wrong scope. Try now.
local tool = script.Parent local plr = tool.Parent.Parent local db = false tool.Selected:connect(function(mouse) mouse.Button1Down:connect(function() if not db then db = true local target = mouse.Target print(target) if game.Players:GetPlayerFromCharacter(target.Parent) then if (target.Parent.Torso.Position - plr.Character.Torso.Position).magnitude <= 7 then target.Parent.Torso.Velocity = plr.Character.Torso.CFrame.lookVector * 150 end end wait(5) db = false end end) end)
all u gotta do is
touching = false
function() if not touching then touching = true --code touching = false
or if it's other stuff then u can rename the touching...
I'm thinking instead of putting db put the actual word "debounce". Maybe that would work.