#I need help for making this touched.connected to only function once

1 messages · Page 1 of 1 (latest)

bleak marsh
#
    if debounce then
        return
    end
    
    local connection
    debounce = true


    connection = Tool.Hand.Touched:Connect(function(hit)
        onTouched(hit)
        end)
    
    if Tool.Hand.CanTouch == false then
        Tool.Hand.CanTouch = true
    end
    
        task.delay(SSpeedCD, function()
            Tool.Hand.CanTouch = false
        debounce = false
        if connection.Connected then
            connection:Disconnect()
            connection = nil
        end
        
    end)
    
end)```