Successfully rendering/replicating an object to every client

I’m currently working on a volleyball game, and I use a Client-Server-Client system to render a ball in the same spot on every client to prevent lag. However, after some extensive testing it seems that most of the time the clients are rendering completely different balls. I use bodyvelocity and bodyforce currently to move the balls. Does anyone have any suggestions/help? I am trying to get all clients to render the exact same ball no matter what.

Code example:

--server script
keypressed.OnServerEvent:Connect(function(plr)
     spike:FireAllClients(function(plr)
end
--local script
spike.OnClientEvent:Connect(function(plr)
     local character = plr.Character
     local hitbox = repstorage.Hitbox:Clone()
     hitbox.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0,1.5,1)
     hitbox.Touched:Connect(function(part)
          velocity.Parent = part
          velocity.Velocity = Vector3.new(10 * character.HumanoidRootPart.CFrame.LookVector.X, 20, 10 * character.HumanoidRootPart.CFrame.LookVector.Z)
          wait(0.2)
          velocity:Destroy()
     end)
end
2 Likes

I’m facing the exact same issue and have hit the same wall. I have no clue how the other Volleyball games do it, I’ve managed to get everything down BUT this.

I assume there’s an invisible ball that is spawned on the server in the same position and linked to the same ball spawned on each client, therefore making all hitboxes function via the server.

The hitboxes are handled via the server because I’ve noticed that with these games, when the user has high latency to the server, the ball still moves smoothly from another player but once you receive the reaction of hitting the ball is delayed, but it still moves smoothly via the client if that makes sense.

But how is this executed? I would love to know too.