2D collision trouble

Hello everyone! I’m having a lot of trouble with making walls that you can’t go through for the past few hours. I tried using code but that didn’t work, so now I’m just letting the physics engine do it for me by adding a box collider and having a rigid body and a collider on the player. However, now, when the player goes up to the wall, it does prevent the player from going through it, but it vibrates.
Thank you,

Do not TALK about code without posting it. Do NOT retype code. Copy/paste and post code properly. ONLY post the relevant code, and then refer to it in your discussion. Do NOT post photographs of code.

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

The most-likely problem:

With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

This means you may not change transform.position, transform.rotation, you may not call transform.Translate(), transform.Rotate() or other such methods, and also transform.localScale is off limits. You also cannot set rigidbody.position or rigidbody.rotation directly. These ALL bypass physics.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

Sorry that I did post any code, I deleted the code I tried using. I did use a transform variable for movement and rotation because the player variable in this is a transform variable.

        //Player Movement
        Vector3 playerInput = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0f);
        transform.position += playerInput * speed * Time.deltaTime;

        //Player rotation
        Vector3 displacement = player.position - Camera.main.ScreenToWorldPoint(Input.mousePosition);
        float angle = Mathf.Atan2(displacement.y, displacement.x) * Mathf.Rad2Deg;
        player.localRotation = Quaternion.Euler(0f, 0f, angle);

So to use a rigidbody would I make a variable public Rigidbody2D player; and then do a getcomponent statement in the start function to get the rigidbody?

If it’s public, just assign it through the inspector.