SetNetworkOwner is not a valid member of model

Hey there, I’m having trouble securing the vehicles in my game:

So, there’s been some advanced exploiters coming into my game manipulating ownership of vehicles in-game as well as house doors. I have a possible fix for house doors, however I’m very new to SetNetworkOwner - as I had just found out about this yesterday.

I’m trying to implement it into our car ownership and it doesn’t appear to be working. Here’s the coding where it functions, along with some extra:

if position ~= nil then
local car
if not police then
car = game.ServerStorage.Cars:FindFirstChild(item):Clone() 
	else
car = game.ServerStorage.Police:FindFirstChild(item):Clone()
end
car.Name = plr.Name
car.Parent = workspace
car:SetNetworkOwner(plr)
car:MakeJoints()
car:MoveTo(position)
car:WaitForChild("Drive", math.huge).Anchored = true

And here’s the error popping up:

Screenshot_761

If anybody with experience using SetNetworkOwner could help, it would be GREATLY appreciated!

2 Likes

you can only use this on Baseparts I believe, maybe try setting ownership of the Root part?

I don’t believe :SetNetworkOwner() is a member of a model, you will have to run it on a basePart.

If I run it on a basepart will this still prevent players from manipulating ownership and making it fly around my city?

car example.rbxm (40.3 KB)

There is an example of the car - I’m just curious as for if, I connect it to a certain part to prevent this exploit from happening. Does it matter which one?

If the code is giving the driver of the car Network ownership, people who aren’t driving the car shouldn’t be able to alter the car until they begin driving it.

It won’t directly stop people from exploiting it, SetNetworkOwnership is mainly required in cars to make the car driving more smoother as if it’s simulated on the server it could be out of sync, giving the driver network ownership will still allow them to fling it around, but only if they are set as the network owner.

it wont exactly stop these exploits, I would give this a read

it basically just determines who handles the physics etc, (the server or the client) to split the workload.

for example, if you are moving the player with the server and the player owns his character, then it’ll be laggy on the server view.

BUT if you move the player with the server and the server owns the character, then it’ll move more smoothly on the server view.

I’ve made the following adjustments:

	if position ~= nil then
local car
if not police then
car = game.ServerStorage.Cars:FindFirstChild(item):Clone() 
	else
car = game.ServerStorage.Police:FindFirstChild(item):Clone()
end
car.Name = plr.Name
car.Parent = workspace
car:MakeJoints()
car:MoveTo(position)
car:WaitForChild("Drive", math.huge).Anchored = true


wait(3)
car:WaitForChild("Drive", math.huge).Anchored = false
	car.Drive:SetNetworkOwner(plr)
return true
end

I did find that article / tutorial and found it rather confusing - I’m certainly much more of a visual learner. It’s moment like these I wish ROBLOXDev Tutorials made more YouTube tutorials / image tutorials on these subjects.

I’m not getting any errors when spawning the car now however.

yeah, it would be nice to have a dedicated section just for video tutorials. (made by roblox, not by the community) and it takes a bit of time to learn, it took me awhile to figure it out too.

im glad you fixed your errors though

Weird idea that ran through my head while testing the new vehicle is the following:

Is it possible to run a check if they are the NetworkOwner, and if false it would anchor the part which would then anchor the model? Just brainstorming a way to fix these exploits.

you could try this

they don’t have an event to check for the change, so you’ll have to make a loop that constantly checks for the change yourself. (which sucks IMO)

you could also do other sanity checks in combination with this, like verifying the vehicle (and players) Y position, making sure they aren’t flying etc.

Verifying the vehicle (and players) y position would essentially make it so they cannot fly around without the player in the vehicle - correct?

Which sure, doesn’t completely patch the exploit. But makes it a lot easier for my moderator’s to locate the exploiter and perm ban them.

That will only prevent them from flying up and down, they will still be able to fly side to side with no restrictions, but it will make it easier to locate them and deal with them. However, you should simply remove the car if that happens as opposed to kicking/banning. As the cars could still be flung

Also, do you assign the server to be the network owner after the player has left the vehicle? If not, a exploiter could teleport into all the vehicles, gain networkOwnership and fly all of them around without even being in them. You could assign the server to be the network owner after the player has left the car