Custom Inventory Client-Server Replication

I have made a custom inventory system with a custom UI (Because I don’t use tools, I use models), but I had a problem with client-server replication, because ping is never 0, the server seems to apply actions late causing problems, for example:

  • Equip an item on client, then unequip it so quickly.
  • Remote event fired so server publicly equips the items so other players can see it.
  • Waiting for server to listen due to ping.
  • Server equips the item then unequips it so quickly but after the player already had the item unequipped.

How would I fix this problem?

1 Like

Unfortunately, there is no real method of completely eliminating ping. If I live in New York and am connected to a server in California, it could take a second for the signal to go through my router, down in some wires, travel across the country, and end up finally arriving at a specific server.

My solution for you is that you could probably have it be immediately controlled by a LocalScript, so here is basically what I mean by that:

  1. Player equips the tool
  2. A LocalScript instantly equips the tool on the client’s side
  3. The LocalScript sends a request to a RemoteFunction, the RemoteFunction sends back a bool to show if the tool is equipped or not on the server, if it is not how expected then you can run another RemoteFunction request until the calls match up
1 Like

Just apply the effect locally and on the server. It will feel instant for the player.

1 Like

The tool gets equipped from client instantly, but it replicates too late so the server repeats what the client did

1 Like

As I said before, send a request to a RemoteFunction on the server. The RemoteFunction should then return what is being seen on the server. Then, you match what is being seen on the server with what is being seen on the client. If they are not the same, issue another request to update them properly to match each other. You could use a simple BoolValue that updates every time the tool is either equipped or unequipped.

1 Like

That is not my problem here, because server always replicates to client, the tool gets properly equipped on the server but late than it’s time on client due to ping, which causes the client to see actions happen twice (Once on client and once on server), I don’t have any problems with the result from server, all items properly equip and unequip

1 Like

From my experience, I haven’t really experienced much of a delay in remote event usage to equip a tool, the delay is minor and I do not believe it affects the gameplay.

1 Like

Players that have internet lag or ping spikes might experience gameplay problems

1 Like

True, I agree with what you are saying, I would recommend him completing it on the client and then just replicating it on the server.

1 Like

Nope, you can’t fix this unfortunately. It will always take some arbitrary time for the client’s response to reach the server. The lower the ping, the less that arbitrary time will be but it won’t be 0 or instantaneous.

Of course there is a delay, though people with the average internet I believe will not experience a delay that is that noticeable, but, again, it is recommended as you guys already pointed out to equip it on the client and then replicate it

How would I replicate Model.Parent from client to server without using a remote event, because roblox backpack tools replicate with no problems because they use built-in roblox replication

You could use :EquipTool(tool instance) to equip a tool.

I’m not using tools, I use models because I use custom grips and I don’t want the backspace button to unequip tools.

First grip it on the client, and then on the server. It is the same action, so the LocalPlayer won’t notice anything neither the other players.

I cannot use tool instances I prefer using models