Do i just set it on the npc group or on each part of the npc?
I believe that this is the way to do it:
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
if descendant:CanSetNetworkOwnership() then
descendant:SetNetworkOwner(networkOwner)
end
end
end
end
Then you can apply this to your NPC.
local NPC = workspace.NPC
-- Make the server the network owner
setNetworkOwnerOfModel(NPC, nil)
8 Likes
This might be a bit more safe:
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 success, errorReason = descendant:CanSetNetworkOwnership()
if success then
descendant:SetNetworkOwner(networkOwner)
else
-- Sometimes this can fail, so throw an error to prevent
-- ... mixed networkownership in the 'model'
error(errorReason)
end
end
end
end
15 Likes