# Connecting different scripts together

**URL:** https://discussions.unity.com/t/connecting-different-scripts-together/657945
**Category:** Scripting
**Tags:** Scripting
**Created:** [March 11, 2017, 7:20am UTC](https://discussions.unity.com/t/connecting-different-scripts-together/657945 "2017-03-11T07:20:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Goldiedog123](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@Goldiedog123](https://discussions.unity.com/u/Goldiedog123)
#### Post date: [March 11, 2017, 7:20am UTC](https://discussions.unity.com/t/connecting-different-scripts-together/657945/1 "2017-03-11T07:20:22Z")

</div>

Hello all,  
sorry if this is a dumb question…

I have 2 C# scripts , one has this little bit of code:

```csharp
void OnPlayerKill(NetworkPlayer player)
    {
        Debug.Log("Cleaning up after player " + player);
        Network.RemoveRPCs(player);
        Network.DestroyPlayerObjects(player);

        int randomSpawn = Random.Range(0, spawnZones.Length - 1); // We're choosing random spawn points from an array just for convenience here - you can handle this how you like, just keep in mind: Network.Instantiate creates the object on everyone's end
        int i = Random.Range(0, Heros.Length);
        GameObject networkPlayer = Network.Instantiate(Heros[i], spawnZones[randomSpawn].transform.position, Quaternion.identity, 0) as GameObject;
        networkPlayer.GetComponent<NetworkView>().RPC("SetUsername", RPCMode.AllBuffered, advancedSettings.username);

    }

```

I am trying to link that void onplayer kill to this other c# script that has this code:

```csharp
void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.name == "earthwall")
        {
            //do the other scripts onplayerkill please
        }

```

How would I actually do this?

Thanks in advance

---

<div class="post-metadata">

### Author: ![der\_r](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/der_r/32/400264_2.png) [@der\_r](https://discussions.unity.com/u/der_r)
#### Post date: [March 11, 2017, 7:53am UTC](https://discussions.unity.com/t/connecting-different-scripts-together/657945/2 "2017-03-11T07:53:06Z")

</div>

In the script with OnCollisionEnter, you put something like this in the Awake method: onPlayerKill = GetComponent()

Then you can access it the other component. You have to make the method public, though.

---

<div class="post-metadata">

### Author: ![Goldiedog123](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@Goldiedog123](https://discussions.unity.com/u/Goldiedog123)
#### Post date: [March 14, 2017, 9:38am UTC](https://discussions.unity.com/t/connecting-different-scripts-together/657945/3 "2017-03-14T09:38:14Z")

</div>

> [@der\_r](#):
>
> In the script with OnCollisionEnter, you put something like this in the Awake method: onPlayerKill = GetComponent()
> 
> Then you can access it the other component. You have to make the method public, though.

sorry der\_r but I have no clue been trying for a few days etc…
