Assuming you have your gun sprite and laser ray sprite ready to use:
You can create an origin point on the muzzle of your gun using the image editor [ besides the default origin point which determines the reference point of the whole image (commonly left in the middle of the image)]
after creating the additional image point, you can refer to it in the events page. lets say your gun is called sprite_gun, and you have the origin point for the image, and you also added an origin point for the muzzle of the gun. these image points will be 0 and 1 respectively. Your laser ray is called sprite_laser
After that, just create an event that creates your laser ray from your gun muzzle and imparts a force on it (or use the bullet & physics behaviours for your laser ray)
example
mouse: on clicked; [/code:3g81g27u] - condition
action - [code:3g81g27u]system: create sprite_laser at position sprite_gun.ImagePointX(1),sprite_gun.ImagePointY(1) and angle sprite_gun.Angle[/code:3g81g27u] (the ImagePoint (1) refers to your gun muzzle, the angle ensures the laser appears at the correct angle according to where the gun is pointing)
action - [code:3g81g27u]sprite_laser: Impart physics force of 20[/code:3g81g27u] (makes the laser shoot forwards)