What I want to achieve:
Find best method for server to client communication with Gui Responsiveness
What Ive Done:
My inventory system in my game allows a player to grab an item from a chest and put it in their inventory, displayed with Gui’s
The current way I handle this interaction is have the client ask the server for permission (remote function) to grab items from the chest.
When the remote function returns I update the Gui showing items from the chest being put into the inventory.
This way it ensures that the back end is taken care of with respective items placed where they need to, before the client can interact with them.
The server will also inform (fire remote event ) all players that this item was taken from a chest and if its displayed on their screen to remove it.
The issue:
When ever I play in studio I have no issues, but when playing in an actual server, there is lag which causes a delay in the front end responsiveness.
I was wondering if this is the best way to handle this.
Or would it be better to do something along the lines of assuming the client is correct (so the Gui’s update instantly), firing a remove event to the server informing that a player wants to grab an item from a chest
The server does its back end job and at the end informs all clients that if it has this item and is not the player who got it to wipe it from their Gui inventory.
The problem I see with this solution is if the player tried to interact with the item and the server hasnt finished putting it in their inventory it would cause other issues.
Is it okay to assume that the client is correct or should I always wait for a response from the server?
If anyone knows a better way to handle these type of task it would be greatly appreciated