Script issue do i have this script right?

HI, I am wondering if I got something wrong on the following script.


$gameVariables.setValue(3, $dataItems[$gameVariables.value(1)]);

So what I am trying to do is

Game Variable #3= the quantity of a specific item which is determined by the vaule of  Variable 1.

Example1:

Item #1 is a Potion
The player has 3 potions in inventory
I want to set Variable #3 to 3.

Example2:

Item #5 is a Rope
The player has 5 potions in inventory
I want to set Variable #3 to 5.

Thanks.
so close.

Code:
$gameVariables.setValue(3, $gameParty.numItems($dataItems[$gameVariables.value(1)]))
What you have is close, but not quite right. You're strong the literal item in the variable, not the quantity the player has. To store the quantity the player has, use $gameParty.itemNumber($dataItems[1]).

Please note, however, that I'm typing this on my phone, and thus can't check what the exact call it a at this moment. However, that is the function call used in Ace, so it should at least be similar.
thank you that worked.

Original thread: https://forums.rpgmakerweb.com/threads/script-issue-do-i-have-this-script-right.52114/