What am I doing wrong here?

Ah, understood. In the original method, there was this line:

JavaScript:
var actor = $gameActors.actor(actorId);

that turned the actorID I stored into an actor object. But there isn't any such code in the other method so it only works when I store the actor itself. That makes sense.

Thank you to everyone, I've actually learned quite a bit.

One final note before the thread can be closed:

I'm slowly reading through this article to learn how things work. Would you recommend any other resources that would help me learn scripting at a good pace?
I'm slowly reading through this article to learn how things work. Would you recommend any other resources that would help me learn scripting at a good pace?
I think going directly to the language's documentation is a pretty incomprehensible way to try to learn if you're not already trained in programming.

Why not Google JavaScript tutorials? I like the series on w3schools, starting with the Statements chapter.

Original thread: https://forums.rpgmakerweb.com/threads/what-am-i-doing-wrong-here.167603/