1

# Why is this debounce nonfunctional?

In this kill script that sucks that remaining parts of the player's character into the center of a part named "orb," the debounce acts as if it weren't there; it inserts the BodyPosition into each body part numerous times. Does anyone know how to make a working debounce for this function?

orb = script.Parent
Debounce = false

orb.Touched:connect(function(toucher) if Debounce == false then Debounce = true else return end --[[debounce wrap]]

human = toucher.Parent:FindFirstChild("Humanoid")

if human ~= nil then character = toucher.Parent else return end

character:BreakJoints()

for i, v in pairs(character:GetChildren()) do

if v.ClassName == "Part" then

v.CanCollide = false

suction = Instance.new("BodyPosition")
suction.Parent = v
suction.D = 100
suction.maxForce = Vector3.new(400000, 400000, 400000)
suction.P = 1000
suction.position = orb.Position

end

end

Debounce = false --[[end of debounce wrap]] end)


1
7 years ago

If you look at your code, there are no wait()s anywhere.

In order for debounce to work, you have to wait() before you reenable the code, otherwise it'll seem like it isn't even there.

What your code currently does is make the function run sequentially, instead of all at once.