How can i fix this error..... (Very new to C#)

Please edit your post to use code-tags . Walls of plain-text are hard to read.

We’ll need to guess which line because you didn’t post the full error which even tells you the line and column. These exceptions are nothing to do with Unity but C# and are by far the most common error new users to the language post on these forums. If you don’t know what a reference is then I would highly recommend you look that up (search for “C# reference value types”; there’s plenty of online tutorials though.

In short: References are things that refer to instances of objects such as your “boxCollider2D” one above. References default to NULL so if you don’t assign anything to it, you’ll get this when you try to do something with it. NULL means nothing, empty, nada, nil, zilch.

If I had to guess, it’s this line which makes no sense: “rb.GetComponent();” I guess you’re trying to assign a Rigidbody2D to “rb” so the error will be here. Presumably you should meant or should’ve copied “rb = GetComponent();”? It’s public so it’s not clear if you’re assing that via the inspector or not.

Certainly you’re not assigning anything to “boxCollider2D” so maybe the above line shoudl be assigning a BoxCollider2D there.