MZ Problems with assigning battler to custom var

I decided to instead of copy pasting huge event function blocks, to assign battler to custom var, and then use it in event function. Problem is, it's either can't define it, or it can identify it.
var SkullTarget == $gameTroop.members()[0];
SkullTarget == $gameTroop.members()[0]
why two ==? You seem to want an assignment (=), not a comparison (== or ===)

and where exactly are you using that code? can you give a screenshot?
Sure, here you go.
1711135738519.png
1711135761177.png
the script command is sandboxed, which means local variables get deleted when the script command is closed.
you either have to store the value in a regular variable or create a global one instead of a local one like you did above.
thats a scoping issue. you lose that variable the second you exit that block of script that defines it because it only exists within it. You can make it global by removing the var at the start of its declaration, or attach the variable to some existing game object like $gameTemp instead

Original thread: https://forums.rpgmakerweb.com/threads/problems-with-assigning-battler-to-custom-var.167061/