How can I create a fully client-sided box script?

I’m trying to make a level-based game that implements boxes that the players can interact with. There will be multiple different stages running in a single server with different “teams” of players working together on each stage. To save resources, I want to make the game mostly client sided, with the server predominately used for interaction between clients and of course anti-exploit checks.

Currently, I have a working box script, but its just a single client interacting with the server. This is how it works:

  1. All of the boxes exist on the server. These are unachored so players can push them around.
  2. A player walks up to a box. Their client picks it up by clicking on the box (UserInputService on MouseButton1).
  3. The client clones the box, and every heartbeat the box location is determined by raycasting from the player’s head to the mouse position.
  4. The cloned box is moved to that position with BodyMovers
  5. Every 5 heartbeats, the current target box position is sent to the server, in which the server box is moved to that position again with BodyMovers.
  6. The player releases the box. The clone is destroyed, and they see the real box again.

Here is a short clip of it working: https://streamable.com/no542x

As shown in the clip, I need the boxes to interact in certain ways:

  • Pushed by walking into it
  • Have buttons detect them (currently done on server by checking a Region3, but I may need to adopt it to the client)
  • Be carried by moving platforms (The platforms are tweened, and the box is moved by raycasting downwards, and if the platform is found the box will move with it)

There’s really a lot to do here, and I don’t really know where to begin. I’ve tried creating clones of the box on all clients when one client picks it up, and teleport the [anchored] server box’s CFrame to the target position, but I’m running into problems with physics as the box should fall when released, but the server box won’t do that. I’ve also had the problem of clients seeing the boxes rest in different positions as they will bounce differently when they fall.

I haven’t really attempted to do something like this, so I don’t know the proper way to go about this. Should boxes even exist on the server, even if they’re hidden? How could I make sure all clients see the box in the same position?

Basically, how can I do something heavily physics based entirely on the client, using the server just as a means of communication?

For better performance detecting when buttons are hit you could raycast from the edges of the box (on server and client so that the server can do the actual action and the client can do the animation).

Then for the boxes in general, you could have body movers in them and when a client requests to move the box, the server set’s network ownership to the client. On the client you could just change the properties of the body mover for them to replicate.

If no one is interacting with the box (picking it up) you could set the network ownership to automatic so that it will look spicy.