Hello! So I have been fighting with pathfinding for a solid amount of time and found out that ‘SetNetworkOwnership’ could perhaps fix the issue, but I guess not for me? I have tried these ways so far:
for _,basepart in pairs(NPCmodel:GetChildren()) do
if basepart:IsA("BasePart") then
nothing works, and no more different tutorials, help please? I am trying to make pathfinding for it to not be laggy/stutter.
You cannot set the network owner of a Model. Instead, you will have to go through every descendant that is a BasePart.
I wrote a module for this that you can use:
local function setNetworkOwnerOfBasePart(basePart, networkOwner)
local success, errorReason = basePart:CanSetNetworkOwnership()
if success then
-- Sometimes this can fail, so throw an error to prevent
-- ... mixed networkownership in the 'model'
local function setNetworkOwnerOfModel(model, networkOwner)
for _, descendant in pairs(model:GetDescendants()) do
-- Go through each part of the model
if descendant:IsA("BasePart") then
-- Try to set the network owner
local function setNetworkOwner(instance, networkOwner)
if instance:IsA("Model") then
elseif instance:IsA("BasePart") then
warn(instance.Name .. "'s network ownership cannot be modified.")
This module throws an error if it fails to set the network owner.
Setting the network owner of every child will not work for NPCs that have hats, since a hat inside a character can also contain a BasePart.
Oh! Thank you! I tried your method before, but it does not work sadly, it always gives me this error:
Put my code in a ModuleScript and load it in your script. Then you can code
local setNetworkOwner = require(path.to.that.module)
Okay, I will try it, I will contact you later on if it succeeded or not.
Sadly, it did not work. Still gives me the error.
That error just means that the npc model is somehow connected to an anchored part or is anchored in itself. Just add a print function before setting the network owner so you can see which part is erroring in case whatever is anchored isn’t obvious
if partnameorwhatever.Anchored == false then
Thank you, I will check it out and try to fix it!!
I have checked it. Every basepart in NPC model errored, none of them are anchored nor welded to another part. Do you have an idea on how it could be fixed perhaps?
I still need help! If anyone is able, then please!
His code has a typo. Instead of
SetNetworkOwnerShip(), it needs to be
SetNetworkOwner() sorry for the bump.