NPC followers turn to the side after I stop walking?

May be a good spot for: local rs=game:GetService(“RunService”)
Then use … rs.Stepped:Wait() … in place of the wait(0.1)
Just a thought as I’ve used this in the past to smooth out jerky movements.

1 Like

This is where It is recommended to use SetPrimaryPartCFrame, setting the position of limb in a rig can break joints and mess with the rig badly. SetPrimaryPartCFrame is not slow, the rig is a small model and each individual limb is always moving anyway…

So should I try his code and replace that part with SetPrimaryPartCFrame? My current code is kinda working as shown in the video in my previous reply though

HumanoidRootPart is not a limb and setting the CFrame of the limb if it is not a RootPart will not do anything.

HumanoidRootParts are recommended to set the CFrame of instead of SetPrimaryPartCFrame, because some unintended parts parented to the character might move around unintentionally. If they are broken joints, this will move the part that is always the root part, and therefore not moving the model unintentionally.

I did research, this is true.

Edit: Actually, I’m not quite sure on some of this (but I’m pretty sure). All I absolutely know is where to place the CFrame. This would be an excellent topic idea, though!

Of course, duplicate the script and disable one of them, and use his script in the other. He could have a solution without any mistakes like I did :laughing:

Nvm, just tested it, didn’t work

Your right, its not a limb but its one of the most important parts of a rig. It also happends to be the most unreliable to set the position.

That is a good point, Its a bit strange to have loose parts inside a character model but if you did for some reason then SetPrimaryPartCFrame would not be what you’d want.

If you were to continuously move a giant map every frame then yes, that would be rediculous. A character model is very small and each basepart in a character is always moving with scripts anyway.

Oh fantastic!
Now in theory, this should print something then create an error. Try this.

print(tostring(X1.." - "..Y2.." - "..Z1))
NPC:SetPrimaryPartCFrame(CFrame.new(CF1.Position) * CFrame.angles(X1, Y2, Z1))


Yep

I wouldn’t be too sure about that, but I’m sure you’re quite mixed up here. The HumanoidRootPart is the most reliable. The most unreliable part is the part with the least mass, and the HumanoidRootPart literally has root in the name. When you call SetPrimaryPartCFrame, it sets the PrimaryPart.CFrame of the model, which is most likely right now the HumanoidRootPart.

Well, this is true, but, at the same time, SetPrimaryPartCFrame should be used to place new models, from my understanding. Like fresh models from ServerStorage meant to be placed down.

But even if you don’t want to set the HumanoidRootPart’s CFrame, you should still at least test the code I provided for you, because I think this might fix the problem. If not, you can revert it just like that, which is why I recommend keeping a backup of the script.

1 Like

I already tested it, it didn’t work though, so I reverted to the backup of my script

1 Like

I’ve set its CFrame using scripts and it endsup offsetting it from the rig.

It sets the CFrame of all parts reletive to the primary part of the model.

I can see why you would think that, but you can really do it with anything.

I think I found the solution, change angles to Angles.
(Difference being the capital A).

robloxapp-20220626-1538037.wmv (2.3 MB)

Alright, it works, but the npcs teleport to the player when they’re close (?)

Maby you could try:

NPC:SetPrimaryPartCFrame(CFrame.new(CF2.Position) * CFrame.Angles(X1, Y2, Z1))

robloxapp-20220626-1542108.wmv (1.7 MB)
there’s a small problem with that

Oh no! Something went horribly wrong?!
Alright listen, that never happened to me before, but this is for another topic. Is the HumanoidRootPart actually connected to the rig and not anchored? Are you using a WeldConstraint?

Correct.

True, but only if the model has a PrimaryPart.

This is the problem I’ve been trying to solve, because I knew it would happen from the start. This is why I believe my solution would have worked better, but doesn’t seem to work?

Alright let me give a revamped example of this one:

and turn it into:

NPC:SetPrimaryPartCFrame(CFrame.lookAt(NPC.PrimaryPart.Position, NPCPos))

Even though it’s way simpler of my original solution, it should push us in the correct direction. I’ve always liked using CFrame.lookAt, so maybe give it a try?

I do know there is a known issue with this, as the NPCs will look up at you if you go higher, but I have a workaround, so I’ll edit the post and remove this part if you need it.


it doesn’t work

Very, very odd. Can we see the code once again? I want to see if everything is placed in the correct location.