You can bypass the code and replace it with a new one. First go to Settings - Parental Settings - press I forgot twice. Then use this website. I was able to reset a secondhand 3DS this way. Good luck!
Thank you! Sorted mine with this