Replicating movement from the client to the server

So currently I am making a tank, I can easily move the car around just by setting the network ownership to the player. The issue is, what is the best way to replicate the rotating turret to the server. I can’t figure out a good way without taking up a bandwidth. I considered using the constraints but that unfortunately did not replicate.

IMO, I think the server will take priority to control the physics of the rotating turret. Because the client wouldn’t had to calculate the physics by themselves.

I am currently making a pretty ambitious project, I am not really handling physics, just a rotating turret. I was originally going to use a body gyro but that had a lot of sideffects that didn’t go well such as the tank flipping over

Oh, I don’t know about that because I haven’t experience with these Body[name] instances yet. I heard that BodyAngularVelocity will turn a part according the speed and direction you set.

Are you done with Rotating the Turret of the Tank? or is still to be done , if its done you can fire a remote event to the server then to all Clients and change the Tank Turret Rotation for each client. I have done this before for Neck Rotation to Mouse and it worked fine .

Actually, that would work pretty well. I can make it so the client doesn’t even do anything if everything is far away. Also I am gonna change the head bob to client fires.

Just a quick question though, when you replicate head movement, how often do you fire the other clients?

I fire the remote event every one second you can change the Interval and make sure the data you are gonna send isn’t very large. Also this won’t be seen for the Server(I mean if you switch to server mode Rotation can’t be seen) But it can be seen by every other client.

EDIT : I change the Neck C0 every Frame in the client , but fire to the other clients only every second. You can follow the same or make some changes.

Yeah what @Razor_IB said works fine. But to add on here is the benchmarking for something like my turret using JsonEncode to measure byte size. For the turret I’m doing it every 0.2 seconds for three Motor6D Instances, and I’m sending the motor6d, and x,y,z orientation data of the C0.

Currently I’m doing on the replication server in order to handle hitboxes on the server like armored patrol but I can switch it up later.

Here is the measurement function:

   local totalDataTransmitted = 0
   local initialTick= tick()
   local function measureBandwidth(...)
      local data = table.pack(...)
      local json = HttpService:JSONEncode(data)
      local dataByteSize = #json
      totalDataTransmitted += dataByteSize
      local timeDifference = tick()-initialTick
      print("Average byte data: ",totalDataTransmitted/timeDifference)
   end

--replication function
                     local motor, x,y,z = turretController:GetLocalC0Orientation()
                     VehicleService.ReplicateMotor6D:Fire(motor, x,y,z)
                     measureBandwidth(motor, x,y,z)

And yeah I got 1200 byte/second so it’s like 2.4% of the 50 KB/s remote limit.

And here is the video of the end result and how it looks like:

1 Like