Log in to vote

Why is this debounce nonfunctional?

Asked by 7 years ago

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


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

        if v.ClassName == "Part" then

            v.CanCollide = false

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



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

2 answers

Log in to vote
Answered by
adark 5467 Badge of Merit Moderation Voter Community Moderator
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.

Log in to vote
Answered by 7 years ago

Also, make sure when you get out of the function, Debounce is set to false.

That is already in his code. User#11893 186 — 7y

Answer this question