How Do Activate an RPC Funcion Before Leaving the Room

Im trying to modify an int trough an RPC Funcion once they leave the room, I tried to use "void OnLeftRoom()" but it wont work for me. Any Ideas why?

Code:

void OnLeftRoom()
{
if (IsOnTeamBlue)
{
PV.RPC("RemoveFromTeamBlue", RpcTarget.AllBuffered, null);
}
else
{
PV.RPC("RemoveFromTeamRed", RpcTarget.AllBuffered, null);
}
}
[PunRPC]
void AddToTeamBlue()
{
TeamBlueCount++;
}
[PunRPC]
void AddToTeamRed()
{
TeamRedCount++;
}
[PunRPC]
void RemoveFromTeamBlue()
{
TeamBlueCount--;
}
[PunRPC]
void RemoveFromTeamRed()
{
TeamRedCount--;
}

(PS: I cant Just run it based on the player count in the room, Becuase i need to check what team is he on, and then remove one from that count)
Sign In or Register to comment.