Use “Touched” event and when player touched to part destroy bodyvelocity and stop animation. Also you can use raycast for it. When player is sliding, raycast through part. If part Y size is more than player’s size or any body part then remove bodyvelocity and stop animation.
Use Raycasting.
Before sliding, fire a ray in front of the character (HumanoidRootPart.CFrame.LookVector.Unit * lenghtOfRay or distanceCoveredBySlideInStuds) and check if it returns a result. If the result is nil, then proceed with slide, otherwise do nothing.
I would also suggest switching BodyVelocity with a VectorVelocity or LinearVelocity because BodyVelocity has been deprecated. Changing it to a more modern constraint may also fix the issue.