Getting a Handgun can be hard if you are not prepared, so take as many health and mana potions (if you’re a mage class) you can with you.
 You can craft a bed using a Sawmill. To craft one, you will need 15 Wood and 5 Silk.

If you don’t have a Sawmill, craft one at the Crafting Table using 10 Wood, 2 Iron/Lead Bars, and 1 Chain.
If you don’t want to craft, you can take a bed from abandoned houses.
 This is used to light up your respawn room.

You can craft a torch with Wood and Gel, or you can buy one from a merchant for 50 coins.
 Bring enough blocks to make a decent-sized room to respawn in. Also bring some wall blocks to fill in the room you will be making., This can be any weapon of your choice; just make sure you have one., The Handgun is only obtainable through the chests found in the dungeon. The dungeon is located at one end of the map, usually opposite the jungle, so head there.


If you still can’t find the dungeon, try walking to one edge of the map. If you find that you’ve reach the ocean, this means that the dungeon is at the other end of the map.
 Once you’ve reached the dungeon, it is recommended that you build a respawn point. The process of building a room is slightly different depending on the platform you’re playing Terraria on:


For PC, hit the ESC key or press the number that the block is assigned to to equip the block then left-click on the area you want to place the block in.
For Xbox, open the inventory menu (Y) and use the D-pad to navigate and highlight a block you want to use. Press A once the block is highlighted, and use the right analog stick to set your cursor to the area you want to place the block in.
For mobile, hit the icon at the end of the Item slots to open the inventory menu. Tap and drag the block you want to use into one of the first five item slots at the top of the inventory menu. Tap the block in the item slot then tap on the area you want to place the block in to build the bedroom.
The minimum required width of a room for respawning in is 9, and the height, 4.
 Cover the room with wall blocks to prevent mobs from spawning there., Open your inventory (ESC on PC, icon on mobile, or Y on Xbox 360), and select the bed. Once you have the bed selected, tap, press A, or click on the area you want to place the bed in.
 Right-click (PC), B button (Xbox 360), or tap (mobile) the bed to set your spawn point. You will get a “Spawn Point Added” notification at the lower-right corner of your screen., Head to the entrance of the dungeon and walk through the door., First you must journey down into the dungeon and fight the mobs there. Along the way, you’ll find chests scattered randomly in the dungeon, and one may contain a Handgun.

Since contents of the chests are random, there’s no guarantee that you’ll get a Handgun on the first, second, or even third run into the dungeon. You’ll just have to be patient and continue going through the dungeon and opening chests until you get a Handgun.
If you die, you will respawn at the bed in the bedroom you built before entering the dungeon.
Bring lots of health and mana potions.
Craft a bed.
Bring a torch.
Bring blocks.
Bring a weapon.
Head for the dungeon.
Build the room.
Place walls.
Place the bed at one end of the room.
Set your spawn point.
Enter the dungeon.
Find chests.
{"src": "wikihow-all_validation", "title": "How to Get a Handgun in Terraria"}