MV Can't equip skill with ID from an array

I'm using YEP_EquipBattleSkills, and i want to equip a skill to an actor with ID from array. When i write an ID everything works fine, but if i write index a strange error appears. I don't understand it at all, why does equipStates even there? I didn't used something like that. Skills doesn't contain it as well (error happens with whatever skill). Did i wrote it wrong?

$gameParty.members()[1].equipSkill($gameVariables.value(15)[1], 3);
I'm using YEP_EquipBattleSkills, and i want to equip a skill to an actor with ID from array. When i write an ID everything works fine, but if i write index a strange error appears. I don't understand it at all, why does equipStates even there? I didn't used something like that. Skills doesn't contain it as well (error happens with whatever skill). Did i wrote it wrong?

$gameParty.members()[1].equipSkill($gameVariables.value(15)[1], 3);
What is in Game Variable 15? Unless something else is going on, it looks like the function is only expecting the Skill's ID so if you have anything other than that in the array, it could cause an issue:
JavaScript:
Game_Actor.prototype.equipSkill = function(skillId, slotId) {...
how did you define the array?
I don't understand it at all, why does equipStates even there?
when you use that equipSkill function, somewhere along the line it looks for the equip states for the battlers skills.

My assumption is that your game variable array isnt actually giving the value you think it is. that equipState property belongs to skills, so that error says that something is expecting to be provided a skill from which it gets that property, but it isnt getting it cause the skill doesnt exist. the value function for game variables returns a 0 if what it finds is undefined. if it returns with a 0, skill 0 is null and it wouldnt have an equipState property
how did you define the array?
My assumption is that your game variable array isnt actually giving the value you think it is. that equipState property belongs to skills, so that error says that something is expecting to be provided a skill from which it gets that property, but it isnt getting it cause the skill doesnt esist. if that array gives a 0, skill 0 is null and it wouldnt have an equipState property
What is in Game Variable 15? Unless something else is going on, it looks like the function is only expecting the Skill's ID so if you have anything other than that in the array, it could cause an issue:

$gameVariables.setValue(15,[$gameParty.leader().battleSkillsRaw()]);

battleSkillsRaw - This returns an array of the skills in their ID form that the actor has
equipped currently.

It works just fine, i wrote a message that gives me an array of ID`s in right order: 220,221,222,223, 224,158,233,89.

So there is nothing else but skill ID`S in the array, and it's not equal 0.

EDIT:
Just wanna say that i'm completely newbie in JS
$gameVariables.setValue(15,[$gameParty.leader().battleSkillsRaw()])
Remove the square brackets here. If it is already an array, you are creating an array of an array, in which case $gameVariables.value(15)[1] will give you nothing since there is nothing in that spot - you are only referring to the outer layer of the array (you would need to do $gameVariables.value(15)[0][1] to get the info based on what you are doing and that's just extra steps).

Try this instead.
JavaScript:
$gameVariables.setValue(15, $gameParty.leader().battleSkillsRaw())

Edit: hurray, I am certain my brain autofills parentheses, etc... maybe I need to go back to NotePad and stop relying on VS Code to autofill/error check... lol...
Remove the square brackets here. If it is already an array, you are creating an array of an array, in which case $gameVariables.value(15)[1] will give you nothing since there is nothing in that spot since you are only referring to the outer layer of the array (you would need to do $gameVariables.value(15)[0][1] to get the info based on what you are doing and that's just extra steps).

Try this instead.
JavaScript:
$gameVariables.setValue(15, $gameParty.leader().battleSkillsRaw)
To think that the answer was that simple. By the way you forgot () after Raw. Thank you, problem solved!
To think that the answer was that simple. By the way you forgot () after Raw. Thank you, problem solved!
The parentheses are my sworn enemy... I am certain my brain autofills them for me and it always happens at the end of code lines lol. Fixed.

Original thread: https://forums.rpgmakerweb.com/threads/cant-equip-skill-with-id-from-an-array.168976/