Attempt to index nil with cframe error(PATHFINDING SERVICE)

SO WHAT IM TRYING TO DO IS TO MAKE THIS NPC FOLLOW A PLAYER BUT IT ENDS UP WITH THIS
ERROR (JUST SAYING IM USING PATHFINDING SERVICE)

THIS IS THE SCRIPT:

THIS IS THE ERROR:
image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I TRYED TO THE CHANGE POSITION WITH CFRAME BUT DIDNT WORK

The player’s character does not have CFrame, you should get the HumanoidRootPart Instead.
Here is how you can do it:

path:ComputeAsync(rig.PrimaryPart.CFrame, player.Character.HumanoidRootPart.CFrame)

for some reason my non player character is not moving still

Do you get any error messages?

i do have an error message:

Workspace.AngryRig.Script:23: attempt to index nil with ‘HumanoidRootPart’

local character = player.Character or player.CharacterAdded:Wait()
path:ComputeAsync(rig.PrimaryPart.CFrame, character:WaitForChild("HumanoidRootPart").CFrame)

I have added few changes to the previous code.

it also didnt work and i will be back after a couple of minutes

Do you get any error messages again?

i go this error:

Unable to cast CoordinateFrame to Vector3

Seems like they arrays needs Vector3 and not CFrame:

path:ComputeAsync(rig.PrimaryPart.Position, player.Character.HumanoidRootPart.Position)