I’m trying to get this debounce to work, and although yes it technically does it, it doesn’t do it as soon as it touches the player, just after a few seconds, and sometimes it just doesn’t work at all, i just want it to have a cooldown when it touches a humanoid, any help?
local ball = script.Parent
local folder = workspace.map
local sound = script.Parent.Sound
local db = true
ball.Touched:Connect(function(part)
if part.Parent.Parent == folder and part.Name == "part" then
sound:Play()
part:Destroy()
end
if db == true then
db = false
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
sound:Play()
humanoid.Jump = true
print("touched")
wait(3)
db = true
end
end
end)
local ball = script.Parent
local folder = workspace.map
local sound = script.Parent.Sound
local debounce = false
ball.Touched:Connect(function(part)
if debounce then
return
end
debounce = true
if part.Parent.Parent == folder and part.Name == "part" then
sound:Play()
part:Destroy()
end
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
sound:Play()
humanoid.Jump = true
print("touched")
end
task.wait(3)
debounce = false
end)
local ball = script.Parent
local folder = workspace.map
local sound = script.Parent.Sound
local db = true
ball.Touched:Connect(function(part)
if (part.Parent==folder or part.Parent.Parent==folder)and part.Name == "part" then
sound:Play()
part:Destroy()
return -- Don't continue when part just destroyed
end
if db == true then
db = false
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
sound:Play()
humanoid.Jump = true
print("touched")
wait(3)
db = true
end
end
end)