Trying to add Collision Detection but it doesnt work

Hey, beginner in unity and c# here. I’ve been following the 10 hour course made by Codemonkey and I am kinda stuck in awkward situation
I’ve been following his tutorial and code 1:1, and now we were supposed to add a cube and some collision detection so we made this code

        float playerSize = .7f;
        bool canMove = !Physics.Raycast(transform.position, moveDir, playerSize);

        if (canMove) {
            transform.position += moveDir * moveSpeed * Time.deltaTime;

But it doesnt work, my character still phases through the cube and the character gets faster depending if there’s an " ! " before the Physics.Raycast

No errors in the console whatsoever