Good day. I recently ran into a problem. I'm creating a multiplayer game, and it returns the following error when i click a button:
NullReferenceException: Object reference not set to an instance of an object
QuickMenu.QuickMenu () (at Assets/Game/GameAssets/Scripts/QuickMenu.js:53)
CompilerGenerated.$adaptor$__BasicComputer_OnGUI$callable0$61_113__$WindowFunction$0.Invoke (Int32 id)
UnityEngine.GUILayout+LayoutedWindow.DoWindow (Int32 windowID) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/GUILayout.cs:307)
UnityEngine.GUI+_Window.Do () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/GUI.cs:985)
UnityEngine.GUI.BeginWindows (UnityEngine.Event e, Int32 skinMode, UnityEngine.IDList idlist, Int32 editorWindowInstanceID) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/GUI.cs:1205)
Here is the code on the button:
if (GUILayout.Button("Get moneyz")) {
theScoreBoard.LocalPlayerHasKilled();
}
And here is the giefmoney function:
function giefmoney(){
var coin : int = 5;
for (var playerInstance : FPSPlayerNode in gameSetupScript.playerList) {
if (Network.player == playerInstance.networkPlayer) {
coin = playerInstance.coin;
break;
}
}
coin++;
//Overwrite the data of other players with the new correct score
networkView.RPC("UpdateMoney",RPCMode.All, Network.player, coin);
}