How can I make an NPC do this?

Hi, I would like to know how I can make an NPC “mimic” player’s movement, so If i walked, the NPC would walk, if I jumped, it jumped. (Not asking anyone to script me an NPC script) I just would like someone to tell me what I can use to make this, for example, I might use AlignOrientation to make the NPC face where I’m facing.

Example of what I mean: How to ACTUALLY Use ITADORI in ABA! - YouTube
(See how the NPC faces where the player faces, and walks when player walks, et cetera)

I’d just like recommendation of methods i can use to achieve this effect, e.g. what method to use so the npc follows me smoothly) etc

2 Likes

in your case part is model.HumanoidRootPart

1 Like

I’ve done this before, when provided the solution to another thread.

You can take the basic idea used (updating the cframe of the clones parts relative to the characters parts) and apply it to the npc’s https://developer.roblox.com/en-us/api-reference/class/Motor6D joints (assuming they are rigged the same) if you want absolute movement replication.

For other things like jumping and walking you can track the player’s humanoid state using the https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged event. Then whenever the state changes you can set the npc’s state the the players state using https://developer.roblox.com/en-us/api-reference/function/Humanoid/ChangeState. You can also use https://developer.roblox.com/en-us/api-reference/function/Humanoid/SetStateEnabled for certain states you don’t want the npc to automatically enter (although the :ChangeState method of the humanoid will ignore this, so make sure you either have a table with what states you want enabled or use https://developer.roblox.com/en-us/api-reference/function/Humanoid/GetStateEnabled). For walking specifically you can use the https://developer.roblox.com/en-us/api-reference/property/Humanoid/MoveDirection.

Using the information I provided, you’ll realize that it everything I’ve done has been in a https://developer.roblox.com/en-us/api-reference/class/LocalScript. The npc, however, should be owned by the server. Just note that the npc movements would be slightly delayed because of the delay for the players character replicating to the server.

However, if you want to sync it to each players render step then you should do it on the client. Each player should have their own local npc. This would be done by tracking the player whose movements are mimicked by the npc on the client. Then you should use the information I gave above accordingly to replicate that characters behavior to the npc.

2 Likes

This helped me a lot, it’s been 3 years and it’s still helpful