Error CS1502 and 1503

Trying to add two player (objects) to a plane, but I keep getting these errors:

Assets/Scripts/GameManager.cs(46,25): error CS1502: The best overloaded method match for `System.Collections.Generic.List.Add(Player)’ has some invalid arguments

Assets/Scripts/GameManager.cs(46,25): error CS1503: Argument #1' cannot convert UserPlayer’ expression to type `Player’

and it’s the same for 50,25.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {

	public GameObject TilePrefab;
	public GameObject UserPlayerPrefab;

	public int mapSize = 12;

	List <List<Tile>> map = new List<List<Tile>>();
	List <Player> players = new List<Player>();
	int currentPlayerIndex = 0;

	// Use this for initialization
	void Start () {
		generateMap ();
		generatePlayers ();

	}

	// Update is called once per frame
	void Update () {

	}

	void generateMap() {
		map = new List<List<Tile>> ();
		for (int i = 0; i < mapSize; i++) {
			List <Tile> row = new List<Tile> ();
			for (int j = 0; j < mapSize; j++) {
				Tile tile = ((GameObject)Instantiate (TilePrefab, new Vector3 (i - Mathf.Floor (mapSize / 2), 0, -j + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<Tile> ();
				tile.gridPosition = new Vector2(i, j); 
				row.Add (tile);
					}
					map.Add (row);
					}
	}

	void generatePlayers() {
		UserPlayer player;

		player = ((GameObject)Instantiate (UserPlayerPrefab, new Vector3 (0 - Mathf.Floor (mapSize / 2), 0, -0 + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<UserPlayer> ();

		players.Add(player);

		player = ((GameObject)Instantiate (UserPlayerPrefab, new Vector3 ((mapSize-1) - Mathf.Floor (mapSize / 2), 0, -(mapSize-1) + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<UserPlayer> ();

		players.Add(player);
	}
}

Does anyone know what I might be doing wrong?

The problem seems to be that in your generatePlayers() function you create a variable of type “UserPlayer” and you try to add it to a list that can only contain the class type “Player”.

If your player class is called UserPlayer then change this line:

List <Player> players = new List<Player>();

to

List <UserPlayer> players = new List<UserPlayer>();

Otherwise if your class is “Player” then in generatePlayers(), change this line

UserPlayer player;

to

Player player;

and the two GetComponent calls to get Player instead of UserPlayer.

You’re try to convert a UserPlayer to a Player. They are different classes so its not going to work (thus you get an error). The issue seems with your lists. You have a list of players and are trying to add UserPlayers to it.
Try changing this:

List <Player> players = new List<Player>();

To this:

List <UserPlayer> players = new List<UserPlayer>();

If that doesn’t work:
Try changing UserPlayer to Player (if the player class is the one that exists). Or you can try casting.

If you have any questions feel free to ask. Hope this helps!