I’m trying to make an npc pathfinding system and I’m having trouble with a line of code that keeps bugging the npc. For some odd reason, using Humanoid.MoveToFinished:Wait() will cause the npc to stop and start walking repeatedly.
What alternative to wait can I use so that the script knows that the npc is done walking but also wont bug movement?
Did you include any wait() after that or did it happen when you get to close the NPC?
I’m not quite sure I understand the question. There is no wait() after I use the Humanoid.MoveToFinished:Wait() and the bug just happens when its been walking around after a while, not when a player comes into contact with the npc.
Not sure about this one, but at the start of the script, put this line of code
HumanoidRootPart:SetNetworkOwner(nil)
Set the primary part of the character NPC to that function.
1 Like
Holy cow!
That actually fixed it. Thank you so much. I have no idea what that is or what it does but my only question is if it has any limitations as to how many times this can be done. I’m planning on having about 20 npcs and I’m wondering if it would allow me to do that with all of them.
Basically, what this does is that it sets the physics calculator of that part to the server. Let me explain.
Network ownership in Roblox is about calculating physics and WHO will be doing it. Client or server? If we do on the client, it would look buggy for everyone because the client’s Ping could be high or low. If we do on the server, everyone will see the same physics calculation. By setting up to the server, it will ignore client’s calculation.
When a client is near to a part, it will take priority to calculate that part’s physics, if it’s far then the server will take control. You can use this function on all other NPCs, make sure to optimize your script.
More information about network ownership is here: Network Ownership | Roblox Creator Documentation
1 Like