Need a lil help with SetNetworkOwner

So i have a item spawn system and i want the tool’s that are dropped to be controlled by the server and not the client for anti-exploit purposes.

Here is the part of the code that has the issue:

clone.PrimaryPart:SetNetworkOwner(nil)
(clone is just a clone of a selected item from a list of items)

And here is the error that i keep getting:

Attempt to index nil with ‘SetNetworkOwner’

These tools have the primary part selected as the handle and its done after being spawned in and i also have a wait() before it.

That error message is saying that your trying to index something with setnetworkowner that is basically nothing

If it is the start of the code put a waitforchild, or check if the primarypart of the clone has been set

Here is the whole function:

local function placeItemOnPart(item, part)
	if item and part then
		local clone = item:Clone()
		clone.Parent = workspace
		clone:MoveTo(part.Position)
		wait()
		clone.Parent = workspace.Drops
		wait()
		clone.Selfdestruckt.Enabled = true
		clone.PrimaryPart:SetNetworkOwner(nil)
	end
end

I dont know how i should implement wait for child in this case.

Have you checked if the clone’s primarypart isn’t set yet, If it hasn’t that is most likely the issue (if it is then set the primarypart = to the humanoidrootpart)

These are Tools. And I have set the Primary Part by every tool as the handle.

	local function placeItemOnPart(item:Tool, part)
		if not item:IsA("Tool") then
			warn("Given Item is not a tool!")
			return
		elseif not item.PrimaryPart then
			warn("Tool does not have a primary part!")
			return
		end

		if item and part then
			local clone = item:Clone()
			clone:PivotTo(CFrame.new(part.CFrame.Position))
			clone.Parent = workspace.Drops
			clone.PrimaryPart:SetNetworkOwner(nil) --also use a custom function like setNetworkOwnerOfModel()
			clone.Selfdestruckt.Enabled = true --?
		end
	end
``` try something like this

Since they are tools, try not using primary part but clone:WaitForChild(“Handle”). You may also need to verify they exist as sometimes issues like this come from something not be welded or anchored causing it to fall out of the world and destroy itself. This probably doesn’t matter if the tool you’re cloning from isn’t in workspace though since your doing it immediately after cloning leaving physics no time to mess with it.

1 Like

Oh, i got confused for a second.

Yeap! Works perfectly now! Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.