Hey guys. I have more of a question of a bit of code, as to why it works.
I have an NPC pathfinding system + ragdolling on death, which was lagging due to problems. I tried alot of different things such as setnetworkowner and a few other tacics. The way i solved this lagging was by adding SetNetworkowner to the local player.
module.SpawnNPC = function(pos, Class)
local NPC = NPCFolder:FindFirstChild(Class):Clone()
NPC:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(pos)
NPC.Parent = workspace
local decendants = NPC:GetDescendants()
for i, v in decendants do
if v:IsA("BasePart") then
v:SetNetworkOwner(game.Players.LocalPlayer)
end
end
return NPC
end
return module
Why did this solve my problem? I look through what setnetworkowner does, and it sets the owner to a single player. How can i set the networkowner to the localplayer? By the way, this does not reduce ping/incoming data, but fixed all my problems.
If i need to make myself more clear please comment.