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

Debounce isn't letting my script repeat?

Asked by 3 years ago
Edited 3 years ago

hello, I'm trying to make a script that when you touch a brick your avatars body parts turn white and your face turns into a different face. I'm trying to add debounce to it, but after the script runs perfectly once , it won't run a second time, but without debounce it can run multiple times. Does anyone know how I can fix this issue while keeping debounce?

local debounce = false 
script.Parent.Touched:Connect(function(hit)
    if debounce == false then
        debounce = true  
    local nameList = {
        FaceCenterAttachment = true,
        FaceFrontAttachment = true,
        HairAttachment = true,
        HatAttachment = true
    }   
    local d = hit.Parent:GetChildren() 
    local scheck = hit.Parent:FindFirstChild("Shirt")
    local hcheck = hit.Parent:FindFirstChild("Accessory")
        hit.Parent.Shirt:Destroy()
        hit.Parent.Pants:Destroy()
        hit.Parent["Right Leg"].BrickColor = BrickColor.new("Institutional white")
        wait(1)
        hit.Parent.Head.BrickColor = BrickColor.new("Institutional white")
        wait(1)
        hit.Parent.Torso.BrickColor = BrickColor.new("Institutional white")
        hit.Parent.Head.face.Texture = "http://www.roblox.com/asset/?id=15431991"
        wait(1)
        hit.Parent["Left Arm"].BrickColor = BrickColor.new("Institutional white")
        wait(1)
        hit.Parent["Right Arm"].BrickColor = BrickColor.new("Institutional white")
        wait(1)
        hit.Parent["Left Leg"].BrickColor = BrickColor.new("Institutional white")
        wait()
        print("checkpoint 1")
            for i, v in pairs(hit.Parent:GetDescendants()) do
                if v:IsA('Accessory') then
                    local attach = v:FindFirstChildWhichIsA('Attachment', true)
                if attach and nameList[attach.Name] then
        v:Destroy()
        elseif v:IsA('Hat') then
                    v:Destroy() 
                    wait(3)
                    debounce = false 
                    end
                end
            end
        end     
end)

0
the problem is your debounce only becomes false when its a hat you should add a wait at the end that makes debounce to true jedistuff2 89 — 3y

Answer this question