How do I change a variable of other objects in Game Maker from a different object?


Usually, you'll want to change an objects variable from that same object during the game. But sometimes you might want to change another object's variable from a different object. Here's how you do it:

Let's say we have two objects: objPlayer and objScore. Let's say objScore has a variable theScore. And let's also say that when objPlayer collides with something, we want to change the score variable in objScore.

In the collision event of the objPlayer with the other object, execute this code:
objScore.theScore += 1;

This code will add 1 to the score when the objPlayer collides with something! Just put the objects name, a period, then the variable name. Epic!

Page updated: March 23rd, 2015 @ 6:21 AM Eastern Time
To help organize our content, all of our game creation tutorial content is moving to our other site:
The move will take about two months to fully complete, so stay tuned!

Game Making Tutorials
Find tutorials about your favorite game creation software! Use the navigation below!

Game Maker: Studio
Help, References, and Tutorials
RPG Maker Fes
Help, References, and Tutorials
Help, References, and Tutorials

Need Help?
Search answers to game development questions or ask a question yourself
Get exclusive updates from!
Join the Email List
Download Books
Search Downloadable Books from
Copyright 2010-2018
All Rights Reserved.