Friend Code

A player's Friend Code screen.
A Friend Code is a series of 12 numbers used to allow access to another player's town during online play via Wi-Fi. A friend code consists of three sets of four-digit numbers separated by hyphens; 1234-5678-9876, for example. Visiting towns allows the player to meet new villagers, explore new town layouts, and find exotic fruits.
Obtaining Friend Codes[]
In Wild World[]
In Wild World, to obtain their friend code, the player must visit the town gate and talking to Copper. They must then select “Friend Code!” and Copper will assign the player with a unique friend code. To actually receive the code, the player must already be connected to the internet via Wi-Fi. To visit another player’s town, the player must have them added to the player's Friend Roster, and the player they are visiting must also have them added to theirs.
In City Folk[]
In City Folk, the process is similar to Wild World. The player will need to talk to Copper at the town gate, while connected to the internet, to receive the friend code initially. After that, the player's friend code can be found in the second tab of the pop-up that appears when they click on the heart icon in the menu that appears at the bottom of the screen. (No longer available)
In New Leaf[]

Nintendo 3DS friend's list shortcut.
New Leaf uses the friend code assigned to the player’s Nintendo 3DS system associated with their Mii. In order to visit another player’s town, both players must have added each other to their Nintendo 3DS friends list. If the player does not have a Mii, they will have to create one first.
Note: The Dream Address assigned to the player by Luna in the Dream Suite is not the same as a Friend Code. This code will not allow the player to visit another player’s town for online play.
Safety[]
Be cautious when giving unknown people your friend code and avoid inviting people you don’t know or trust to visit your town. When a player visits a town they have the ability to destroy flowers, cut down trees, place/pick up patterns, dig holes everywhere and potentially ruin your game entirely by placing seeds in your town.