Unity 2D stop player when hit collider

Hy there. First, sorry for my bad english, im not native.
Second: I few days ago i start playing around with Unity
Third: I want to stop my player when he hits a collider. I gave him the static variable “Player” in a other code. But in this code i can’t stop his movement. The code from "
function OnTriggerEnter2D (hitInfo : Collider2D) {
if (hitInfo.name == “Player”) {
Debug.Log (“Game Over”);" works fine. Here is my code:

#pragma strict

var "Player" : Rigidbody2D;

function OnTriggerEnter2D (hitInfo : Collider2D) {
	if (hitInfo.name == "Player") {
		Debug.Log ("Game Over");
		rigidbody2D.velocity.x = 0;
		rigidbody2D.velocity.y = 0;
	}
}

I hope you can help me.

Untested, but I believe this is what you want:

#pragma strict
 
var "Player" : Rigidbody2D;
 
function OnTriggerEnter2D (hitInfo : Collider2D) {
    if (hitInfo.name == "Player") {
       Debug.Log ("Game Over");
       hitInfo.rigidbody2D.velocity = Vector2.zero;
    }
}

That is, you want to use the hitInfo to address the player’s rigidbody2d, not set the rigidbody2d on the object this script is attached to.