Photon Instantiate

Hello,

I have a massive issue. I want objects to be spawned when the server is created and everyone who connects can see the object.

As i only want it to spawn the object when the room is first created and not joined, i added this:

void OnCreatedRoom()
	{
		PhotonNetwork.Instantiate ("tree", tree1.transform.position, tree1.transform.rotation, 0);

This works fine. When the room is created the tree is spawned in the correct place. The issue is, say another person connected, it would create another tree…

So two players = two trees but i just want it so there is one tree for all players. I could simply just make it client side however it needs to be on network for reasons.

If anyone could tell me why its instantiating a tree per person i would be greatful.

var wasCraeted : boolean = false;
void OnCreatedRoom()
{
if(wasCreated != true)
{
PhotonNetwork.Instantiate (“tree”, tree1.transform.position, tree1.transform.rotation, 0);
wasCreated = true;
}
}