Event error

Hi guys i have an error called NullReferenceException: Object reference not set to an instance of an object

It only happens in the Update function and when im trying to run it in OnGUI it doesn’t give that error

This is my code

if(Event.current.keyCode == KeyCode.Return)
	currentChatMessage = String.Empty;

I’d say, wherever you define ChatMessagesyou need to:

List<string> ChatMessages = new List<string>();

The Event class is for use inside OnGUI. I believe Event.current will be undefined if it’s not used inside OnGUI.