A toy gun comprising: a body for firing dummy bullets; a bolt assembly provided inside the body so as to move forward or backward in the process of loading and firing the dummy bullets; and a driving portion provided inside the body so as to drive the bolt assembly in order to load and fire the dummy bullets, the driving portion comprising: a ratchet gear configured to receive power from a driving motor that drives the driving portion; a piston gear that receives power from the ratchet gear and moves the bolt assembly backward; and a ratchet assembly configured to selectively transfer, to the piston gear, power transferred to the ratchet gear, the ratchet assembly comprising: a piston gear cap that penetrates the ratchet gear and is coupled to the piston gear in the state where the ratchet gear is fitted into the center of the piston gear cap; and a ratchet pole configured to slide in one direction with regard to the piston gear cap, wherein an engaging groove, into which the ratchet pole is inserted, is provided on the inner circumferential surface of the piston gear such that power of the driving motor is selectively transferred to the piston gear as the ratchet pole is inserted into and released from the engaging groove. a body for firing dummy bullets; a bolt assembly provided inside the body so as to move forward or backward in the process of loading and firing the dummy bullets; and a driving portion provided inside the body so as to drive the bolt assembly in order to load and fire the dummy bullets, the driving portion comprising: a ratchet gear configured to receive power from a driving motor that drives the driving portion; a piston gear that receives power from the ratchet gear and moves the bolt assembly backward; and a ratchet assembly configured to selectively transfer, to the piston gear, power transferred to the ratchet gear, the ratchet assembly comprising: a piston gear cap that penetrates the ratchet gear and is coupled to the piston gear in the state where the ratchet gear is fitted into the center of the piston gear cap; and a ratchet pole configured to slide in one direction with regard to the piston gear cap, wherein an engaging groove, into which the ratchet pole is inserted, is provided on the inner circumferential surface of the piston gear such that power of the driving motor is selectively transferred to the piston gear as the ratchet pole is inserted into and released from the engaging groove. a ratchet gear configured to receive power from a driving motor that drives the driving portion; a piston gear that receives power from the ratchet gear and moves the bolt assembly backward; and a ratchet assembly configured to selectively transfer, to the piston gear, power transferred to the ratchet gear, the ratchet assembly comprising: a piston gear cap that penetrates the ratchet gear and is coupled to the piston gear in the state where the ratchet gear is fitted into the center of the piston gear cap; and a ratchet pole configured to slide in one direction with regard to the piston gear cap, wherein an engaging groove, into which the ratchet pole is inserted, is provided on the inner circumferential surface of the piston gear such that power of the driving motor is selectively transferred to the piston gear as the ratchet pole is inserted into and released from the engaging groove. a piston gear cap that penetrates the ratchet gear and is coupled to the piston gear in the state where the ratchet gear is fitted into the center of the piston gear cap; and a ratchet pole configured to slide in one direction with regard to the piston gear cap, wherein an engaging groove, into which the ratchet pole is inserted, is provided on the inner circumferential surface of the piston gear such that power of the driving motor is selectively transferred to the piston gear as the ratchet pole is inserted into and released from the engaging groove.