Player stuck tilemap glitch

Hello! I have this pretty annoying and unfixable bug. I have a player and have assigned it some code to make a platformer phisics. I encounter the following problem: at some random point when the player is moving on the ground (it has a box collider attached) it just stumbles upon an invisible barrier. When i jump (i use arrow keys) itovercomes the invisible obstacle. I am using unity’s tilemaps for the ground and i feel like this could be the problem. This is my code for the player’s left/right movement.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

public class PlayerMoveScript : MonoBehaviour
{
    public KeyCode LeftKey;
    public KeyCode RightKey;
    public float LeftRightMoveSpeed;
    private Rigidbody2D playerRB;
    public string collisionDirection;
    private void Start()
    {
        playerRB = gameObject.GetComponent<Rigidbody2D>();
        collisionDirection = "";
    }
    void Update()
    {
        // Move & prevent stuck on wall glitch
        if (Input.GetKey(LeftKey) && collisionDirection != "left")
        {
            playerRB.velocity = new Vector2(-LeftRightMoveSpeed, playerRB.velocity.y);
        }
        // Prevent slipperiness
        else if (Input.GetKeyUp(LeftKey))
        {
            playerRB.velocity = new Vector2(0, playerRB.velocity.y);
        }
        // Move & prevent stuck on wall glitch
        if (Input.GetKey(RightKey) && collisionDirection != "right")
        {
            playerRB.velocity = new Vector2(LeftRightMoveSpeed, playerRB.velocity.y);
        }
        // Prevent slipperiness
        else if (Input.GetKeyUp(RightKey))
        {
            playerRB.velocity = new Vector2(0, playerRB.velocity.y);
        }
    }
}

Here is a video, where i show what the problem looks like:
Space jumper - Level 1 - Windows, Mac, Linux - Unity 2021.3.23f1 Personal DX11 2024-05-14 20-24-26 MConverter.eu
As you can see, the velocity goes to 7.5, but the gamobject doesn’t move at all.
If anyone can solve the problem, please help!

If someone else is searching for the solution, I’ve found it. You just have to add a composite collider to the tilemap gameobject and on the tilemap collider check the used by composite checkbox. This makes the collider one big piece for the whole tilemap chunk.