Player goes through slopes when turning around

I’m using Sebastian Lague platformer 2d code, which uses raycasting.

The code didnt have anything to make the sprite turn left or right depending on what direction you’re going, so I decided to add it, however I ran into a problem; If the player is on a slope and I change the direction (on the X axis) he clips through it.

This is what I added:

void Flip()
    {
        // Switch the way the player is labelled as facing.
        m_FacingRight = !m_FacingRight;

        // Multiply the player's x local scale by -1.
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;
    }

The problem seems to be "theScale.x *=-1; Without that line the sprite won’t change when changing directions but it doesnt go through slopes. Help please! I can post the entire code if needed.

Hey I fixed it

Apparently I could just use SpriteRenderer.FlipX = true to flip the character without messing with the collisions so all I did was:

public void FixedUpdate()
{
    if (Input.GetAxisRaw("Horizontal") < 0)
    {
        spriteRenderer.flipX = true;
    }
    if (Input.GetAxisRaw("Horizontal") > 0)
    {
        spriteRenderer.flipX = false;
    }
    }

Doing

SpriteRenderer spriteRenderer; 

and

spriteRenderer = GetComponent<SpriteRenderer>();

before.