How to :SetNetworkOwner of model?

I am making a simple car with motors and stuff, and I’m trying to set the network owner of the car to the person driving it to make it smoother but I’m not sure how to. Here’s my code:

local players = game:GetService("Players")
local chassis = script.Parent.Parent.Chassis -- This is the PrimaryPart of the car model
local vehicleseat = script.Parent
vehicleseat:GetPropertyChangedSignal("Occupant"):Connect(function()
	script.Parent.Parent.Chassis:SetNetworkOwner(players:GetPlayerFromCharacter(script.Parent.Occupant))
end)

Also, I’m not sure how to do this without making the car exploitable. The car has scripts in it so I started out completely forgetting about the whole network ownership thing and just made the car work with the scripts being normal server scripts. But it had some latency to it so I made the scripts into local scripts and tried to make the car network owned by the player, but wouldn’t this make it exploitable? Is the local script thing necessary? Thanks

1 Like

Assuming the model is one entity all joined together, you can simply set the network owner of the primary part, and it will set the whole model automatically.

3 Likes

Adding on to metatablecat’s reply (the solution): wheels, hinges, etc are counted as connected for network ownership.

As far as exploiting, the character can already fly so if a car can fly too it’s probably not terrible. You can do similar stuff as preventing characters from flying (checking (on the server) if the car is on the ground, just destroying the car if it ends up flying some how, etc).

You very probably want a player controlled car to have client ownership.

2 Likes

Is that not what I’m doing? I for sure have the model’s PrimaryPart set as the chassis and I’m setting the chassis network owner to the player but it’s still always owned by the server. And yes the car is all connected with hinges and welds.

1 Like

Nevermind I figured it out. I was using :SetNetworkOwner and I needed to use :SetNetworkOwnerAuto

1 Like

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