You dont need to script anything for this to work. The character should automatically pathfind the path if a path is possible.
Do you maybe have any other action clips on that character that control it’s position? Do you maybe have an Animator Track with Root Motion enabled (in which case the Root Motion is taking over)?