Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

debounce disables script from working?

Asked by 6 years ago
local debounce = false

script.Parent.Touched:connect(function(hit)
    if not debounce then

        debounce = true

        wait(0.3)
    script.Parent.closeddoors.Transparency = 0
    script.Parent.closeddoors.CanCollide = true
    script.Parent.opendoor1.Transparency = 1
    script.Parent.opendoor2.Transparency = 1
    wait(3)
    if hit.Parent:FindFirstChild('Humanoid') then
        hit.Parent.Torso.CFrame = CFrame.new(-13.084, 122.459, 989.779)
        script.Parent.closeddoors.CanCollide = false
    script.Parent.closeddoors.Transparency = 1
    script.Parent.opendoor1.Transparency = 0
    script.Parent.opendoor2.Transparency = 0
    wait()
    debounce = false
    end
end)

the script does not work when i added debounce and my best guess is the wait function at the beginning

but i don't know

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

Looks like you're missing an end

You have two if statements within your function, but only one end!

local debounce = false

script.Parent.Touched:connect(function(hit)
    if not debounce then

        debounce = true

        wait(0.3)
        script.Parent.closeddoors.Transparency = 0
        script.Parent.closeddoors.CanCollide = true
        script.Parent.opendoor1.Transparency = 1
        script.Parent.opendoor2.Transparency = 1
        wait(3)

        if hit.Parent:FindFirstChild('Humanoid') then
            hit.Parent.Torso.CFrame = CFrame.new(-13.084, 122.459, 989.779)
            script.Parent.closeddoors.CanCollide = false
            script.Parent.closeddoors.Transparency = 1
            script.Parent.opendoor1.Transparency = 0
            script.Parent.opendoor2.Transparency = 0
            wait()
            debounce = false
        end
    end
end)

Indenting helps identify issues like these :)

0
Correct User#19524 175 — 6y
0
kthx spunkworks 110 — 6y
Ad

Answer this question