MV Having property errors, need a different scripts I think

So I need to check which weapon and armour are equipped and previously I was given this script:

$gameActors.actor(1).equips(1)[0].id === 42
But it said it can't read property "id" of null

But TBH it's not really the script I want anymore
I was to use the variable command and set the variable to the id of the armour equipped
However, because the game has hats, tops, leggings and boots how can I check for a specific hat equipped because 4 armour would be equipped at once right? so it can't set the variable to 4 different types of armour

Anyone know a script to change a variable to the ID of a specific type of armour equipped by a specific actor?
$gameActors.actor(1).equips(1)[0].id === 42
I don't know where you got this script, because it has several things wrong. The equips() function simply returns the array of the actor's equipment, passing it a 1 doesn't do anything. Additionally, any time you look at a part of an array (the number in brackets), you want to check that it exists first. If you run this code and a character doesn't have anything equipped in slot 0, it will crash with the error you're getting. So the correct version of this would be:
Code:
if ($gameActors.actor(1).equips()[0] && $gameActors.actor(1).equips()[0].id === 42)
I was to use the variable command and set the variable to the id of the armour equipped
However, because the game has hats, tops, leggings and boots how can I check for a specific hat equipped because 4 armour would be equipped at once right? so it can't set the variable to 4 different types of armour
That's exactly what the 0 in the brackets is doing, you're checking a specific equipment slot. Now it doesn't look like the right slot, by default - go to your database and look at the Types tab, then look all the way to the right where it says equipment types. That's the order that your equipment is listed in the array that you're getting from equips. The default for head is slot 2, not 0.

Incidentally, if you're just checking that value to see if they're wearing a specific hat, why would you set it to a variable?

However, you can do this even more efficiently with just one function, which I found from Googling "RPG Maker MV check equipped armor":
Code:
$gameActors.actor(1).isEquipped($dataArmors[helmetID])

where the 1 is the ID of the actor you're looking at, and the helmetID is the ID of the helmet you want to check for (looks like 42, in your case).
So these scripts didn't work for me, I'm not sure why?
But I found another script and I can verify it worked
JavaScript:
$gameParty.isAnyMemberEquipped($dataArmors[13])
13 is the ID of the armour in the database in the list of armour and I put it in a conditional branch. However, the only downside is that it won't check the particular party member
BUT! For me, I actually don't want it to be a specific party member so this saves time.
Well, at least in this thread you never said exactly what you wanted to accomplish, so I was just fixing what you posted originally 😉 I definitely recommend you do some basic JavaScript tutorials so that you have some ability to understand what the functions are doing - right now you're kind of grabbing at things in the dark and hoping they work.

I'm glad you found a solution that works for you. Good luck with your game!
Yeah, I'm sorry, I should actually try and learn javascript. I am trying to do something really odd like normal. I have 1 more question so where you have ($dataArmors[13])
Is it possible to make 13 be the value of a variable so ($dataArmors[ whatever variable 90 currently is equal to? ]
I've seen this $gameVariable.value before but clearly I don't know much about javascript so idk
($dataArmors[gameVariables.value(X)])

replace the X with the ID of the variable.
($dataArmors[gameVariables.value(X)])
screenshot3.PNG
I get this, which is weird coz I define the variables with the number in the bracket
@petpous

Oh sorry, I forgot the "$".

Try ($dataArmors[$gameVariables.value(X)]) instead.

Original thread: https://forums.rpgmakerweb.com/threads/having-property-errors-need-a-different-scripts-i-think.136296/