I’m trying to spawn an NPC right now. The workflow is fairly simple: one script copies an NPC into the Workspace and then that NPC starts its code. I’m having an absolutely mind-boggling issue right now though: SetNetworkOwner is failing.
The specific error tells me that SetNetworkOwner does not work with anchored parts. The thing is, I do not have any anchored parts whatsoever. I even printed the anchorship of every single BasePart descendant and each iteration returned false.
Save my soul, this small issue made my game stay down for 2 days.
The code involved in this is below, under a script called Mind. This runs almost instantaneously when placed in the Workspace, as is custom for any kind of script that’s transferred from ServerStorage. Everything else has been removed as it is not relevant to include.
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Head = Character:WaitForChild("Head")
function networkOwnership()
for _, part in pairs(Character:GetDescendants()) do
if part:IsA("BasePart") then
print(part.Anchored) -- Debug condition
-- Even using part.Anchored = false does not fix
part:SetNetworkOwner(nil)
end
end
end
function init()
networkOwnership()
-- Truncated here
end
init()
To be clear: I’m not looking for anti-pattern alternatives, such as using waits before running anything.