How to Fix Runtime Errors in Gamemaker Studio 2

There are many different types of errors Gamemaker can throw at you, but most it’s most likely you got a runtime error. In Gamemaker, when you get a runtime error, a big white window will appear, showing some valuable information about the issue.

Example of a runtime error in Gamemaker Studio 2:
Example of a runtime error in Gamemaker Studio 2

Runtime errors are typically laid out like so:

_______________________________________________
###############################################
FATAL ERROR in
action number [x]
of [event with error]<Ctrl> Key
for [object of event with error]:

[error type]
at [error position]
###############################################
-----------------------------------------------
stack frame is
gml_Object_[object with error]_[event with error]
(line [line number with error])

The first thing you’ll want to do is to go to the event which has the error, and look at the line number in that event. Check and see if anything is wrong. Is something spelled incorrectly? This is the most common reason for runtime errors.

If you see any red exclamation point icons (error icon), you should hover over those with your cursor and it will tell you what’s wrong on that line.

Gamemaker Studio 2 error icon in code
Gamemaker Studio 2 error icon in code hovered

If there are no red exclamation point icons, you should also check if there are any yellow triangle icons (warning icon). Likewise, hover your mouse over those icons if they are present.

Gamemaker Studio 2 warning icon in code
Gamemaker Studio 2 warning icon in code hovered

In most cases, finding and fixing these little icons will do the trick. However, sometimes it’s not this straightforward. Certain error messages will have a negative value as the “action number”. These values can be used to pinpoint the exact nature of the error and what it refers to the following values possible. Below is a table of each value and what it refers to:

Error type Error code
-1 Self
-2 Other
-3 All
-4 Noone
-5 Global
-6 Not specified
-7 Local


Additionally, Gamemaker provides us developers with an entire list of all possible errors as seen in this article (thanks, Gamemaker!). Below is the entire list of possible errors:

Error type Error code What it means
Comparisons DoSet :: Invalid comparison type This denotes that the runner has tried to compare two incompatible data types, like a real number with a string.
Conversions DoConv:: Execution Error This denotes an error in the conversion of one data-type into another.
Addition DoAdd:: Execution Error Something has gone wrong when using the addition (+) expression.
Multiplication DoMul:: Execution Error Something has gone wrong when using the multiplication (*) expression.
Subtraction DoSub:: Execution Error Something has gone wrong when using the subtraction (-) expression.
Subtraction DoSub:: Execution Engine - Cannot operate on string type You are trying to subtract the wrong type of variables (for example subtract a string from a real).
Division DoDiv:: Execution Error Something has gone wrong when using the division (/ or div) expression.
Division DoDiv:: Execution Engine - Cannot operate on string type You are trying to divide the wrong type of variables (for example divide a string by a real).
Division DoDiv:: Divide by zero You are attempting to divide by 0.
Remainders DoMod:: Execution Error Something has gone wrong when using the modulo (mod) expression.
Remainders DoMod:: Execution Engine - Cannot operate on string type You are trying to use modulo on the wrong type of variables (for example mod a string by a real).
Bitwise And DoAnd:: Execution Error Something has gone wrong when using the bitwise “and” (&) expression.
Bitwise And DoAnd:: Execution Engine - Cannot operate on string type You are trying to use “and” on the wrong type of variables (for example trying to “and” a string with a real).
Bitwise Or DoOr:: Execution Engine - Cannot operate on string type You are trying to use “or” on the wrong type of variables (for example trying to “or” a string with a real).
Bitwise Xor DoXor:: Execution Error Something has gone wrong when using the bitwise “xor” (^) expression.
Bitwise Xor DoXor:: Execution Engine - Cannot operate on string type You are trying to use “xor” on the wrong type of variables (for example trying to “xor” a string with a real).
Bitshift Left DoShl:: Execution Error Something has gone wrong when bitshifting left («) a value.
Bitshift Left DoShl:: Execution Engine - Cannot operate on string type You are trying to left bitshift the wrong type of variables (for example trying to bitshift a string).
Bitshift Right DoShr:: Execution Error Something has gone wrong when bitshifting right (») a value.
Bitshift Right DoShr:: Execution Engine - Cannot operate on string type You are trying to right bitshift the wrong type of variables (for example trying to bitshift a string).
Negative DoNeg:: Execution Error You are trying to turn a variable type into a negative when this type does not permit such an operation.
Not DoNot:: Execution Error You are trying to “not” a variable type when this type does not permit such an operation.
Stack Push Push:: Execution Error - Variable Index out of range (var) The variable being accessed is out with the established range for the runner.
Stack Push Push:: Execution Error - Variable Get (var) The given variable has not been defined or is unknown.
Stack Pop Pop:: Execution Error - Variable Index out of range (var) The variable being accessed is out with the established range for the runner.
With Cannot use global in with statement You have tried to use “global” as a variable within a “with” statement.
With Cannot use local in with statement You have tried to use “local” as a variable within a “with” statement.
General DoCall:: Execution Engine type error This is an undefined error within the Virtual Machine. You should file a bug report with Gamemaker should this happen.
General Stack Overflow… A stack overflow occurs when too much memory is used on the call stack and when your game attempts to use more space than is available on the call stack (that is, when it attempts to access memory beyond the call stack’s bounds, which is essentially a buffer overflow), the stack is said to overflow, resulting in a program crash. Restart your computer and GameMaker: Studio and if the error persists please get in touch with support and/or file a bug (as explained above).

About The Author

Mike Miller
Mike Miller Since the age of nine, Mike Miller has been coding his own games, visualizations, and other technological projects.

Comments