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.
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:
Player equips the tool
A LocalScript instantly equips the tool on the client’s side
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
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.
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
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