var i=player.GetComponent();
for(b=0;b<=i.items.Length; b++){
if (i.items**==gameObject){**
** Debug.Log(“YES! There is have a”+ItemName);**
** }**
but giving this error:IndexOutOfRangeException: Array index is out of range.
var i=player.GetComponent();
for(b=0;b<=i.items.Length; b++){
if (i.items**==gameObject){**
** Debug.Log(“YES! There is have a”+ItemName);**
** }**
but giving this error:IndexOutOfRangeException: Array index is out of range.
The error says that the array index is out of range. This means that the index (b) doesn’t exist in that array. Your problem is that you start at 0 and go all the way up to Length, including Length.
If you have 5 items in your array, the index goes from 0 to 4. (0 1 2 3 4 is five items). When you try to access items[5] it throws “index out of range” error because there is no such thing as an item at position five.
To solve your problem, change
b<=i.items.Length
to
b < i.items.length