beginner syntax error..

“BCE0019: ‘xxxx’ is not a member of ‘UnityEngine.Component’.”

I am currently trying to follow some basic tutorials for a better understanding of scripting within unity in javascript but recently I have come across an error witch I have been unable to solve. In this case I am trying to access a variable from one script to use in a second one by using the GetComponent function but it always gives me an error anytime I use the GetComponent function be it a variable or even if i try to access other functions(I get the same error).

Example

// player script
var lives                    : int    = 3;
var playerSpeedHorizontal    : float = 10.0;
var playerSpeedVertical      : float = 10.0;
var horMin                   : float = -4.0;
var horMax                   : float = 4.5;
var verMin                   : float = -3;
var verMax                   : float = 2.7;
var projectile               : Transform;
var sockets                  : Transform;

function Update ()
{
    var transV : float = Input.GetAxis("Vertical")*playerSpeedVerticalTime.deltaTime;
    var transH : float = Input.GetAxis("Horizontal")playerSpeedHorizontal*Time.deltaTime;
    
    transform.Translate(transH,transV,0);

    transform.position.x = Mathf.Clamp(transform.position.x,horMin,horMax);
    transform.position.y = Mathf.Clamp(transform.position.y,verMin,verMax);

    if(Input.GetKeyDown("space"))
    {
        Instantiate(projectile,sockets.position,sockets.rotation);
    }
}


//script asteroid

var asteroidSpeed : float = 6.0;
var explosion : Transform;

function Update ()
{
    transform.Translate(Vector3.downasteroidSpeedTime.deltaTime);
    if(transform.position.y <= -5)
    {
        transform.position.y = 5;
        transform.position.x = Random.Range(-4.0,4.5);
    }
}


function OnTriggerEnter(other : Collider)
{
    if(other.gameObject.tag == "player")
    {
        other.GetComponent("script player").lives-=1;
    }
    ResetEnemy();
}


function ResetEnemy ()
{
    transform.position.y = 5;
    transform.position.x = Random.Range(-4.0,4.5);
}

In this example I am trying to substract the variable lives found in script one accessing it with script two by using the GetComponent function.But when it compiles it gives me the BCE0019 error.This error also appears even if i create a separate function to substract the variable lives.

Any help and an explanation would be appreciated.

other.GetComponent(“script player”).lives-=1;

that should be without the “” so like this:

other.GetComponent(script player).lives-=1;

but that might make some errors and that is because the name of the script has a space in between, try to avoid spaces, what I like to do is use underscores so the name would be:
script_player or what you could do is use capitals like ScriptPlayer, personally I would’ve named it PlayerScript so:

other.GetComponent(script_player).lives-=1;

Oh, and please format your code, it was unreadable like that, formatting is like using tabs and stuff.

-Hybris

It’s a casting problem.

(other.GetComponent(scriptPlayer) as scriptPlayer).lives -=1;