Cant chance transform of a object in list

Hi , i have a list which is holding my gameobjects inside List objects; i want to chance transforms of this objects .

But its giving me error : u cant chance transform bcs its private ( Error Code CS0200)

You can’t swap the transform component of a game object, nor can you simply swap out any other components either.

Are you actually trying to swap their positions? What’s your end goal here?

my goal is chancing players locations with the slots locations

Right, then you would assign to the transform.position property with the slot’s same property.

1 Like
players[i].transform.position = slots[i].position;
1 Like

Just FYI:

players[i].GetComponent<Transform>.transform

is the same as:

players[i].transform