BodyGyro and BodyPosition not replicating to server

so im creating a custom suspension system for a car. everything works on the server but as soon as the player gets in the driver seat the body gyro and position stop doing anything

External Media

what i do when the player gets in the seat is:

  • disable the server car controller (this disables the body position and gyro on the server by setting their max force/torque to 0)
  • give the player network ownership of the entire vehicle
  • client starts their car controller (creates new body position/gyro and starts the main loop)

anybody know why the body movers arent moving the car

Post your script so we can see how you are doing it.

When a player sits on a VehicleSeat they automatically get network ownership of the car. I think if you have passenger seats you may have to disable their occupant’s network ownership (I could be wrong).

From your description it sounds like your script is all local, which doesn’t control the server aspects.

in the video before i sit in the car it was being controlled by the server
as soon as the player sits in the seat it gives the player network ownership and server stops controlling the car

im using a driver seat so i dont have to make my own input system

this is ran when the player sits in the seat:
(server)

function component:giveNetworkOwner(player, model)
	if model == nil then
		model = self.model
	end
	
	for i, v in pairs(model:GetDescendants()) do
		if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("VehicleSeat") or v:IsA("Seat") then
			if v:CanSetNetworkOwnership() then
				if v:GetNetworkOwner() == nil then
					v:SetNetworkOwner(player)
				end
			end
		end
	end
end

self.driverSeat:Sit(player.Character.Humanoid)

self.carController:disable()
self:giveNetworkOwner(player)
setMass(player.Character, true)

local client = driverClient:Clone()
client.Model.Value = self.model
client.Parent = player.Character

and this is ran when the driverClient scripts runs

local carController = CarController.new(model, setting)
carController:start()

CarController.new just initialize all the components required for the car to work

  • the body movers (gyro/position)
  • set up the wheels’ throttle vector force and friction vector force

CarController:start starts the main loop to calculate everything

CarConroller:disable sets the max force/torque of the body movers to 0 and disables the vector forces and disconnects the main loop (basically destroying but still keeping them there)

both of these functions are the same client and server

I guess part of my question is why do you need to set the ownership of the car assembly? Roblox automatically sets the vehicleseat and everything attached to it to the Occupant of the VehicleSeat when they sit.

Why do you have 2 BodyGyros and 2 BodyPositions in the car chassis? An issue could be if your script searches for a BodyGyro in the chassis and sets it’s parameters, and the other script searches for a BodyGyro but picks the other one the parameters may not be properly read or changed.

Another thing is that BodyGyro and BodyPosition have been deprecated. They still work, but if Roblox doesn’t support them anymore you may get issues in the future.

it doesnt give the player network ownership automatically plus stuff werent replicating so i always do it

there is 2 because one is the server and one is the client, the server is just disabled. i dont want to constantly destroy and recreate it when people keep leaving and getting in the car, so its easier to just disable it

-- creation of the body movers
self.bodyPosition = Instance.new("BodyPosition")
self.bodyPosition.D = 10
self.bodyPosition.P = 200
self.bodyPosition.MaxForce = infVector
self.bodyPosition.Position = self.model.Base.Position
self.bodyPosition.Parent = self.model.Base

self.bodyGyro = Instance.new("BodyGyro")
self.bodyGyro.CFrame = self.model.Base.CFrame
self.bodyGyro.D = 200
self.bodyGyro.P = 2000
self.bodyGyro.MaxTorque = infVectorXZ
self.bodyGyro.Parent = self.model.Base

the script doesnt search for the body mover because it creates it

im using body position and gyro because they are easier to control over the newer version of align orientation and position, plus i tried switching to the new ones and nothing worked. these body movers work just fine so why switch

1 Like

after messing around for a bit turns out the issue was a dumb error on my end
so its fixed now

1 Like

Please post what the error was which might help people reading the post in the future.

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