how do i get the name of an actor who used an item

i want to make an item with a common event that says the name of the actor who used it, but i'm not sure how to do that
i know how to do this but with the actor's id instead but that's not what i want
BattleManager._subject.name()

Store that in a variable and then show the variable in show text with: \V[X]

EDIT: Since it's unclear if you want the user or the target, you'll need to edit that script if you want the target.
In tye damage formula, you can put v[1] = a.actorId; in front of the formula.

Normallybyou would use \n[1] to get the name of actor 1.

Now you can do \n[\v[1]] to get the name of the caster.

(Untested)
both of these do not work unfortunately
BattleManager._subject.name()
putting this in the variable results in an error screen when the common event is played
\n[\v[1]]
this for some reason results in "[function () { return this._actorId; }]" instead of the actor's name
this for some reason results in "[function () { return this._actorId; }]" instead of the actor's name
Try v[1] = a.actorId(); instead of v[1] = a.actorId;.
Try v[1] = a.actorId(); instead of v[1] = a.actorId;.
at first i thought this worked but then i realized that this just puts the first actor's name into the variable, not the actor using the item
Hmmm, what I wrote above works for me. I tested it.

EDIT: You should show a screen shot how you did it.
@rpgLord69 maybe a screenshot so he can compare what you did?

the way @Mac15001900 works too though, so I wonder what he does wrong
to get the errors 😛
@Mac15001900 works too though, so I wonder what he does wrong to get the errors 😛
if the code can only be executed during battle then that's the problem
this item is not battle only, it is supposed to be used outside of it too

i'll probably test out the code a bit more than before
So do you want the user of the item or the one who the item was used upon, in the menu screen? I think the user is automatically selected based on pharmacology (maybe only healing items, don't know). If you want the one the item was used upon in the menu, you can put it in a variable with:

$gameActors.actor($gameParty._targetActorId).name()

Then make a conditional in the common event:

IF $gameParty.inBattle()
-> the script for the battle from earlier
ELSE
-> the script from this message

But yeah, if you need the id of the one who used the item outside of battle, someone else is going to have to help you.

EDIT: And if you do want the target, you'll need to edit the battle script too.
You'll need to differentiate in the common event if it is battle or not with a conditional branch (script portion). I'll sort of write out how the commands look like visually in the common event and you can go from here:
JavaScript:
◆If:Script:$gameParty.inBattle()
  ◆Script:let i = BattleManager._action._targetIndex;
  :      :let a = $gameActors.actor($gameParty.members()[i].actorId());
  ◆Comment: Code goes here and/or add more to the script above

:Else
  ◆Script: let i = $gameParty._targetActorId;
  :      : let a = $gameActors.actor(i);
  ◆Comment: Code goes here and/or add more to the script above
:End

Here are the script calls for copying convenience:
JavaScript:
$gameParty.inBattle()

let i = BattleManager._action._targetIndex;

let a = $gameActors.actor($gameParty.members()[i].actorId());

let i = $gameParty._targetActorId;

let a = $gameActors.actor(i);

Edit: haha got ninja'd by @rpgLord69 . Nice.

2nd Edit: if you are using the "v[1] = a.actorId()" in the damage formula and are confident that you are the one using it (and not an enemy), you can reference that instead of using the BattleManager scripts. At this point though, a plugin with notetags would be much more efficient and probably with less errors.
@rpgLord69 okay so both of your scripts worked when it came to grabbing the name of the actor and putting it into the text thing, but it didn't do anything else in my common event (which was to immediately kill the actor that used the item)

also if anyone wants me to elaborate on what i did with mac's script, i put it into the formula like i was told to do, but it was the only thing i put into the formula, no extra code
it worked exactly as i wanted it to, minus the first actor being the only person being put into the variable
Yeah well, wasn't your question how to get the name? Of course they won't kill your actor. You'll need to put that in as well.

And if you go the damage formula route, replace 'a' with 'b', so you'll get the target's name.
Oh I forgot the ().

\n[\v[1]] should work, if variable 1 contains the ID of the actor

To be sure, that last piece does not go in the battle formula, but in wherever you want to show that name.
And if you go the damage formula route, replace 'a' with 'b', so you'll get the target's name.
alright, i've tested this out and my common event now works
thanks rpglord, johndoenews and mac

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-get-the-name-of-an-actor-who-used-an-item.167620/