1
\$\begingroup\$

I am following along with a guide. I'm trying to reference code from an instance in my room, but whenever I try to run the script I get this error:

ERROR in action number 1 of Create Event for object objSmileyFace:

Variable objHealth.(100004, -2147483648) not set before reading it.

at gml_Object_objSmileyFace_Create_0 (line 4) - objHealth.playerHealth = objHealth.playerHealth + 10;

gml_Object_objSmileyFace_Create_0 (line 4)

It says objHealth is not set, which is not true. What am I doing wrong?

Code screenshot

\$\endgroup\$
3
  • 2
    \$\begingroup\$ "I am following along with a guide" - which guide? Include a link. \$\endgroup\$
    – DMGregory
    Commented Sep 5, 2020 at 22:44
  • \$\begingroup\$ A uDemy course created by Aaron Craig called 'Learn To Code by Making Video Games - No Experience Needed!' \$\endgroup\$ Commented Sep 6, 2020 at 3:34
  • 1
    \$\begingroup\$ Since users trying to help you won't necessarily have that guide to follow, you should edit your question to walk through the steps you took to get here. With that, we should be able to reproduce the problem in a new project, spot steps that might be missing or incorrect, and test potential solutions. \$\endgroup\$
    – DMGregory
    Commented Sep 6, 2020 at 10:11

1 Answer 1

2
\$\begingroup\$

The objSmileyFace object is likely created before the objHealth exist.

If you're going to the room where these are defined, check the instance layer and see if both objects are present. and if objHealth is called before objSmileyFace. (priority depends on the order in the instance layer)

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .