SetNetworkOwner breaks my NPCs

  1. What do you want to achieve? Fix an issue I’m having with SetNetworkOwner()

  2. What is the issue? For some reason, my NPCs break when I use SetNetworkOwner on them. I use SetNetworkOwner to avoid delay in calculating the velocity for the NPCs to ragdoll.
    Unfortunately, when using SetNetworkOwner, it makes the NPCs… fly away???


    After I shoot the enemy it should just ragdoll on the ground, but instead when using SetNetworkOwner, ragdolls, but then just moves directly upward, forever. When I remove the line of code that sets the NetworkOwner, it works normally, though has a delay, which SetNetworkOwner fixes.

It should just do this:

The code I use to SetNetworkOwner is the following:
local Descendants = Char:GetDescendants()
for i = 1, #Descendants do
local Descendant = Descendants[i]
if Descendant:IsA(“BasePart”) then
Descendant:SetNetworkOwner(Player)
end
end

NPCs shouldn’t have a network owner as a player. Their scripts are controlled by the server, and if the server can’t access their physics, then the physics will break.

Thanks for the info, I’ll try to use a client-sided ragdoll, and I’ll mark this as solution if it works out, thanks.

You could have the server just delete the NPCs, and fire a remote to all clients saying to render a ragdoll there instead (same NPC model), this would work, and be even more efficient, as the server would not need to replicate the physics from one client to all other clients this way, as each client would have the NPC locally.

1 Like