[Photon] rpc error Exception: cannot serialize(): UnityEngine.CapsuleCollider

Im trying to make some kind of inventory system that allows the players to pickup and drop weapons. Im just starting out. Heres the script:

using UnityEngine;
using System.Collections;

public class GrenadeLauncher : Photon.MonoBehaviour {
	public GameObject Player = null;

	void Update () {
		if (Player != null) {
			Debug.DrawLine(transform.position, Player.transform.position);
			transform.position = Player.transform.position;
			transform.rotation = Player.transform.rotation;
			collider.enabled = false;

			if (Player.GetComponent<PhotonView>().isMine) {
				if (Input.GetKeyDown("g")) {
					photonView.RPC("Playernull",PhotonTargets.AllBuffered);
				}
		}
		}
		else {
			collider.enabled = true;
		}
	}
	void OnTriggerEnter (Collider col) {
			if ( col.gameObject.tag == "Player") {
			GameObject send = col.gameObject;
			photonView.RPC("Playeris",PhotonTargets.AllBuffered,send);
			}
}
	[RPC]
	public void Playernull()
	{
		Player = null;
	}
	[RPC]
	public void Playeris(GameObject recive)
	{
		Player = recive;
	}
}

the Error im getting when the RPC´s are called is
Exception: cannot serialize(): UnityEngine.CapsuleCollider
and the weapon is not picked up.

I can’t seem to understand whats wrong.
Help is much apreciated.

You cannot send GameObjects trough RPC calls like you’re doing in the Playeris function. RPCs only support basic data like floats, ints, bools, Vector2 and 3 and Quaternions.

I recommend setting an ID or name for the gameobject instead, sending that ID trough the RPC function, and then looking up the GameObject from the ID on the other end.

I’ve just released a GameObject Serializer Pro which will allow you to serialize complex Unity objects, such as GameObjects and Components and send them through RPC calls. So, it would technically be possible.

I should give the caveat though, that you probably don’t actually want to serialize an entire player GameObject (even though you can). Looking at your script, it would cause an entire “Player” object copy to pop out of the other end on every collision.

You may still be able to make use of GameObject Serializer Pro to serialize more complex types than Photon allows.