So I am setting up an inventory system and I have slots which hold objects. However, whenever I use the following code, the image of the parent(slot) changes to the desired sprite instead of the image of the child(item):
Hi, GetComponentInChildren() returns the component of the GameObject itself too (see documentation).
I guess it returns the one from the GameObject before the one from the child objects (and it won’t return the one from inactive child gameobjects). This could explain why your code changes the one from the parent object and not the child.
To access the child item’s component: you can use transform.GetChild( childIndexNumber ).GetComponent()
Without more detail as to the hierarchy & code we can only guess, but assuming you want to change the first child, try executing this code in the script on the parent;