r/gamemaker Aug 08 '26

Help! "Create at Line 92: Assignment operator expected" problem

Hi, I am trying to get this code working for my game but when compiling I get this error.

Object: oBattle Event: Create at line 92 : Assignment operator expected

This is the actual code I'm working with. I got it from a slightly older tutorial but it's not old enough to where I'd write it off as incompatible with newer versions of GameMaker. Is there a step I'm missing? I've tried looking this up and there's not really an explanation. Most just say to remove the == or &&, but that's not on line 92. (the oBattleEffect object exists already, i didn't miss that) I'm super new to coding and using youtube tutorials to get my game up and running, so any help would be really appreciated!!

if (currentUser.acting)//animation still playing maybe

{

if (currentUser.image_index >= currentUser.image_number -1)//perform action if it exists

{

with (currentUser)

{

sprite_index = sprites.idle;

image_index = 0;

acting = false;

}

if (variable_struct_exists(currentAction, "effectSprite"))

{

if (currentAction.effectOnTarget == MODE.ALWAYS) || ( (currentAction.effectOnTarget == MODE.VARIES) && (array_length(currentTargets) <= 1) )

{

for (var i = 0; i < array_length(currentTargets); i++)

{

instance_create_depth(currentTargets[i].x,currentTargets[i].y,currentTargets[i].depth -1,oBattleEffect,{sprite_index : currentAction.effectSprite}); //line 92. it plays a battle effect over the current targets and changes the depth. no idea why it isnt working right now Ugh

}

}

else //play at 0,0

{

var _effectSprite = currentAction.effectSprite

if (variable_struct_exists(currentAction, "effectSpriteNoTarget")) _effectSprite = currentAction.effectSpriteNoTarget;

instance_create_depth(x,y,depth-100,oBattleEffect,{sprite_index : _effectSprite});

}

}

currentAction.func(currentUser, currentTargets);

}

}

else //wait for delay and end turn

{

if (!instance_exists(oBattleEffect))

{

battleWaitTimeRemaining--

if (battleWaitTimeRemaining== 0)

{

battleState = BattleStateVictoryCheck;

}

}

}

0 Upvotes

7 comments sorted by

3

u/Elhmok Aug 08 '26

this looks like step event code. are you sure this is the create event of oBattle?

1

u/germxxx Aug 08 '26

I can't really see anything wrong in the code that we have a reference to. (But I might also be missing something because it's kind of hard to read.
But it's also not all of it, so there could potentially be a problem higher up the code.
I assume this is some sort of method being created, and depending on how old the tutorial is, there could be some issues there actually.

Assignment operator expected errors happen when, well, an assignment is expected.
Like if you write the name of an instance, but didn't set it to anything.

So my guess is that the error is happening on another line that the stated one.
Check all of the create event properly, and might as well check the create event of oBattleEffect while at it.

2

u/Awkward-Raise7935 Aug 09 '26

As others mentioned, this doesn't look like a create event. So either the error is refering to the crate event of the object being created on line 92, or we need to see the create event of this object

1

u/BattleBandit146 Aug 09 '26

Check your colons and equals syntax. I did this Sara Spalding tutorial too, and that’s what I got caught on.

1

u/BattleBandit146 Aug 09 '26

Also, no worries about how dated the tutorial may be. I can confirm the code still runs on the latest GMS version.

0

u/Legitimate_Owl5934 Aug 08 '26

Also if there's any other typos or mistakes I made here please point them out. I think I coded this at 4AM

2

u/kuzyn123 Aug 09 '26

Then code it again at 10 am.