Q:

How can determine the number of instances of an object in Game Maker?

I am making a small puzzle based game.  I want the number of instances of an object to be equal to the ammo count plus 2.
Each time a new room is loaded, the main object's creation method with run this script:
var ammo = instance_count(jellyfish)+2;

Then each time a bullet is fired, I subtract one. When there is no ammo left, the player goes to the 'failure' room.
However, I get the error: Unknown function or script: instance_count.
I have see this script on Google, but am not sure if it has deprecated or not. Is there a way I can do this? 

A:

The function you want is instance_number(obj) (documentation found here). 

This functions returns the number of instances of a object that exist
  in the current room.

