Calling variables and functions

I made these scripts when i was using unity 3, now i’m using unity 4, but i can’t understand why this isnt working now? This worked before updating…

var multiplayerscript;
multiplayerscript = GameObject.Find("Networking").gameObject.GetComponent(CoOp);

And I use this for things like this:


Error message for that was:
Assets/Scripts/Menu/Menu.js(14,19): BCE0019: ‘startServer’ is not a member of ‘Object’.

I dont think you need this part of networking script, but i’ll show it too. So I was calling this function:

function startServer(){
Network.InitializeServer(2,menuscript.remotePort, !Network.HavePublicAddress);
MasterServer.RegisterHost(gameName, "blabla", "blabalabal");

var multiplayerscript:CoOp;
multiplayerscript = (CoOp) GameObject.Find(“Networking”).gameObject.GetComponent(CoOp);

This one should work. Declaring as var multiplayerscript will create object of Object class that holds any datatype. Sp always specify the class name while declaring.

The casting in the second line is just in case if it doesnt work. it wont be error if u remove it too.