Idk try changing the root priority of the humanoird root part higher.
Otherwise try testing the script in an empty baseplate.
It could also be because your joints and rig are setup differently and the C1 or part1 has some rotation to it which messes up the calculations.
Sounds like something wrong with the raycast at it uses the part0 up vector so the raycast could never hit anything.