1 Error im a newb help please

Error:

FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s)
MenuManager.Menu_HostGame () (at Assets/Scripts/MenuManager.cs:109)
MenuManager.OnGUI () (at Assets/Scripts/MenuManager.cs:44)

using UnityEngine;

using System.Collections;

 

public class MenuManager : MonoBehaviour

{

    public string CurrentMenu;

    public string MatchName = "Welcome";
	
	public string MatchPassword = "";
	
	public int MatchMaxPlayers = 32;
 

    void Start()

    {

        CurrentMenu = "Main";

    }

 

    void OnGUI()

    {

        if (CurrentMenu == "Main")

            Menu_Main();

        if (CurrentMenu == "Lobby")

            Menu_Lobby();

        if (CurrentMenu == "Host")

            Menu_HostGame();

    }

 

    public void NavigateTo(string nextmenu)

    {

        CurrentMenu = nextmenu;

    }

 

    private void Menu_Main()

    {

        if(GUI.Button(new Rect(10,10,200,50), "Host Game")) //GUI.Button if a method that returns a bool, needs an if block.

        {

            NavigateTo("Host");

        }

    }

 

    private void Menu_HostGame()

    {

        if(GUI.Button(new Rect(10,10,200,50), "Back")) //Again... the if.

        {

            NavigateTo("Main");

        }

 

        if(GUI.Button(new Rect(10, 60, 200, 50), "Start Server"))

        {

         

        }
		
		
		GUI.Label(new Rect(220, 10, 130, 30), "MatchName");
		MatchName = GUI.TextField(new Rect(400, 10, 200, 30), MatchName);
		
		
		GUI.Label(new Rect(220, 50, 130, 30), "MatchPassword");
		MatchPassword = GUI.PasswordField(new Rect(400, 50, 200, 30), MatchPassword,'*');
		
		
		GUI.Label(new Rect(220, 90, 130, 30), "Match Max Players");
		GUI.Label(new Rect(400, 90, 200, 30), MatchMaxPlayers.ToString());
		MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 32);
		
		
		if(GUI.Button(new Rect(425, 90, 25, 30), "+"))
			MatchMaxPlayers += 2;
		if(GUI.Button(new Rect(450, 90, 25, 30), "-"))
			MatchMaxPlayers -= 2;
	
    
	
	}

    private void Menu_Lobby()

    {

    }

}

You edited the script or didn’t paste everything because System.Int32.Parse is not used anywhere.

Thanks but that didnt help i dont really under stand i posted the whole thing where should i put that ?

Can u post ur full script.
Without seeing error part how can i solve the error?.

using UnityEngine;

using System.Collections;

 

public class MenuManager : MonoBehaviour

{

    public string CurrentMenu;

    public string MatchName = "Welcome";
	
	public string MatchPassword = "";
	
	public int MatchMaxPlayers = 32;
 

    void Start()

    {

        CurrentMenu = "Main";

    }

 

    void OnGUI()

    {

        if (CurrentMenu == "Main")

            Menu_Main();

        if (CurrentMenu == "Lobby")

            Menu_Lobby();

        if (CurrentMenu == "Host")

            Menu_HostGame();

    }

 

    public void NavigateTo(string nextmenu)

    {

        CurrentMenu = nextmenu;

    }

 

    private void Menu_Main()

    {

        if(GUI.Button(new Rect(10,10,200,50), "Host Game")) //GUI.Button if a method that returns a bool, needs an if block.

        {

            NavigateTo("Host");

        }

    }

 

    private void Menu_HostGame()

    {

        if(GUI.Button(new Rect(10,10,200,50), "Back")) //Again... the if.

        {

            NavigateTo("Main");

        }

 

        if(GUI.Button(new Rect(10, 60, 200, 50), "Start Server"))

        {

         

        }
		
		
		GUI.Label(new Rect(220, 10, 130, 30), "MatchName");
		MatchName = GUI.TextField(new Rect(400, 10, 200, 30), MatchName);
		
		
		GUI.Label(new Rect(220, 50, 130, 30), "MatchPassword");
		MatchPassword = GUI.PasswordField(new Rect(400, 50, 200, 30), MatchPassword,'*');
		
		
		GUI.Label(new Rect(220, 90, 130, 30), "Match Max Players");
		GUI.Label(new Rect(400, 90, 200, 30), MatchMaxPlayers.ToString());
		MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 32);
		
		
		if(GUI.Button(new Rect(425, 90, 25, 30), "+"))
			MatchMaxPlayers += 2;
		if(GUI.Button(new Rect(450, 90, 25, 30), "-"))
			MatchMaxPlayers -= 2;
	
    
	
	}

    private void Menu_Lobby()

    {

    }

}

From what I am seeing, it looks like the error comes from this line:

MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 32);

Can you try putting this before the label or outside of the OnGUI function?

Oh thanks it worked sorry for double posting i just really wanted to get it out of the way so i could carry on with my game :slight_smile: i know there will be an error soon should i just post it again or just comment here ?

Explanation: (For other people’s benefit)
When you called MatchMaxPlayers.ToString(), it may have accidentally converted MatchMaxPlayers into a string, therefore, causing Mathf.Clamp to throw an exception because it doesn’t accept a string. The format exception error was there because the input was wrong and it is asking you to give it an integer (which you did but ToString() made it a string for some reason).

Anyway, explanation is based on my observation. Interesting to note for my reference though =)

well heres another challange for you if you want ive got another 2 errors but there the same its annoying ive looked at if tryed fixing but i cant work it out

Errors:
Assets/Scripts/MultiplayerManager.cs(13,42): error CS0029: Cannot implicitly convert type char' to string

Assets/Scripts/MultiplayerManager.cs(11,38): error CS0029: Cannot implicitly convert type char' to string’

This is where the error is ?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MultiplayerManager : MonoBehaviour
{
	public static MultiplayerManager instance;
	
	public string PlayerName;
	
	private string MatchName = '*';
	
	private string MatchPassword = '*';
	
	private int MatchMaxUsers = 32;

Full code here

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MultiplayerManager : MonoBehaviour
{
	public static MultiplayerManager instance;
	
	public string PlayerName;
	
	private string MatchName = '*';
	
	private string MatchPassword = '*';
	
	private int MatchMaxUsers = 32;
	
	
	public List<MPPlayer> PlayerList = new List<MPPlayer>();
	
	void Start ()
	{
		instance = this;
	}
	
	
	
	public void StartServer(string servername, string serverpassword, int maxuser)
	{
	MatchName = servername;
		
	MatchPassword = serverpassword;
		
	MatchMaxUsers = maxusers;
		
	Network.InitializeServer(MatchMaxUsers,2550, false);
		
	Network.InitializeSecurity();
	}
	
	void OnServerInitialized()
	{
		Server_PlayerJoinRequest("", Network.player);
	}
	
	void OnConnectedToServer()
	{
		networkView.RPC("Server_PlayerJoinRequest", RPCMode.Server,"" , Network.player);
	}
	
	void OnPlayerDisconnected(NetworkPlayer id)
	{
		networkView.RPC("Client_RemovePlayer", RPCMode.All, id);
		
	}
	
	[RPC]
	void Server_PlayerJoinRequest(string playername, NetworkPlayer view)
	{
		networkView.RPC("Server_PlayerJoinRequest", RPCMode.All, view);	
	}
	
	[RPC]
	void Client_AddPlayerToList(string playername, NetworkPlayer view)
	{
		MPPlayer tempplayer = new MPPlayer();
		tempplayer.PlayerName = playername;
		tempplayer.PlayerNetwork = view;
		PlayerList.Add(tempplayer);
		
	}	
	[RPC]
	void Client_RemovePlayer(NetworkPlayer view)
	{
		
		MPPlayer temp1 = null;
		
		foreach(MPPlayer p1 in PlayerList)	
		{
			
			if (p1.PlayerNetwork = view)	
			{
				
			}
			
		}
		if (temp1 != null)
		{
			PlayerList.Remove(tempp1);
		}
		
	}
}

public class MPPlayer
{
	public string PlayerName = "";
	
	public NetworkPlayer PlayerNetwork;
}

I suggest you take some programming course since the errors are very basic.

    private string MatchName = '*';
    private string MatchPassword = '*';

Both are wrong, you should use double quotes instead of single
’ != "

is there any online ones i can take ? ive struggled to find some

I sent Private message to u…

all you need is right there : http://lmgtfy.com/?q=learn+C%23