Setting NetworkOwner to an NPC

I set NetworkOwner to all the limbs of an npc,` so the client can’t move it. But whenever I tried moving the npc’s head on the client, it moves on the client. I wonder why. This is very bad, as we can kill the npc even when the server sees us hitting nothing.

Here’s the script.

local dummy = script.Parent:GetChildren()

for i, v in pairs(dummy) do
	if v:IsA("BasePart") then
		
		local success, errorReason = v:CanSetNetworkOwnership()
		
		if success then
			v:SetNetworkOwner(nil)
		else
			error(errorReason)
		end
	end
end
2 Likes

I don’t know why we have to do this, can someone explain it to me? is it like the pcall() function thing? Like I don’t know how it can either return the value for succes or errorReason.

1 Like

Does the sword use LocalScripts to detect the hit, and then sending it to the server by RemoteEvent to deal damage?

1 Like

No, the sword uses a server script for the hit detection. It’s the default roblox sword.

I’m pretty sure that the client will always be able to move it, it just won’t replicate for others if the network owner is set to nil.

1 Like

yeah, but how do you prevent the client killing the npc from a far distance? if the npc dies, it replicates to the server. (I’m having doubt with if it will replicate to the server)