Adding a score in GameMaker
Creating a Score in GameMaker
-
Create a score object, call it objScore
-
Add a Create event to the object and set up a global variable to store the score:
global.pscore = 0; -
Add a Draw event to this object to draw the score to the screen
//draws the score in the top left corner draw_text(40, 20, "Score: " + string(global.pscore)); -
Open your enemy object. On the collision event with your player laser or wherever you have checked that the enemy’s health has reached zero add the following code, inside the if condition:
global.pscore += 1;Your code will end up looking something like this:

-
If you want something to happen when your score reaches a certain size, on the player object Step event you could add something like this code:
if global.pscore=10 //when score reaches 10 end the game room_goto(EndRoom1); -
Add the score object to your game room
Additional Resource:
Here is an old video that shows you how you can set your font type and colors in GameMaker. Use these functions inside the Draw event.

Learning GameMaker?
Code Create Play takes you through building a complete game step by step over seven days.