How to set a parts network ownership to the client

I have a train game and each train has a few hundred parts. The parts on the train networkowner ship is set to the server and I think it is what is causing the train to lag. So how do i set it to client cause I only know how to set it to server. Any help is appreciated

1 Like

NetworkOwnership is only able to be used on the Server, not the Client, you can set Network Ownership to the Player, or just nil.

You can use a RemoteEvent

1 Like

How do i set the networkownership to player. I currently only know how to set it to server

1 Like

On the server, use part:SetNetworkOwner(player)

2 Likes

One example could be done with a RemoteEvent:

Example.OnServerEvent:Connect(function(player) -- Event + Player

YourObject:SetNetworkOwner(player)
end)
3 Likes

Thanks so much. Really appreciate the help

2 Likes
local Train = script.Parent -- Change this to the train

local function setOwnership()
	for i,v in pairs(Train:GetDescendants()) do
		if v:IsA("BasePart") and not v.Anchored then
			v:SetNetworkOwner(player)
		end
	end
end

wait(1)
setOwnership()


I did this but there is a red line under error and it says “Unknown Global Player”

Use a RemoteEvent, not a standard function

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