Tested good in GMS2.
Allows you to fire a laser beam at enemy and decrease its hit points. Laser beam has varying strength settings based on how long the space key is held.
More geared towards platform games but can adjust the code as required. Code is fully commented.
IMPORTANT: You must ensure each enemy has obj_Enemy as the parent.