Mouse triggered ragdoll instantiation

So I’m working on a game, where for whatever reason I would want to have a ragdoll fall from the sky when the mouse button is pressed. I’ve been searching for quite a while now, and I can’t find a solution. Here is my progress so far:

public GameObject[] ragdolls = new GameObject[5];
	public Transform player;
	int index = 4;

	void Update()
		if (index <= 0) 
			index = 4;
		else if (Input.GetMouseButtonDown(0) == true)
			Debug.Log("Mouse pressed");
			ragdolls[index].transform.position = new Vector3 (player.position.x, player.position.y+100, player.position.z);
			index = index-1;


With the array I intended to save memory, and recycle my ragdolls after a while.
So, once again: I intend to spawn a ragdoll prefab in the sky when the mouse button is pressed.
Thank you for the help! Have a nice day!

Use Input.MousePosition (raycast)