Does the server recognize changes made cliently to playergui?

My drag and drop system handles switching inventory slots on the client’s side, does the client need to communicate this change to the server? I’m having issues with the server thinking that the item is still in it’s old slot, so if I were to pick up another item, it would update the old slot instead of the new one where the item is currently occupying.

1 Like

To answer your question, no it will not recognize changes made to GUIs on the client’s side.

What you can do, is fire a remote event for when they pick up and item, and have the client handle the updating of your inventory, so that there is no interference.

1 Like

Sorry, what do you mean by client handling the updating? If the server is conducting the switch, wouldn’t the player automatically receive whatever changes were made on the server?

it would, he probably meant update UI on the client side through the usage of RemoteEvents “triggered” from the server either to reduce load, altering properties for objects server-side saves the work.

2 Likes

What I mean by “handling the updating” is that you said the server still thinks an item is still in its old slot, even when it is. So what I mean is that instead of having the server add the item to your inventory(or however it works in your game) fire a remote event that tells the client to add the item instead. This will eliminate the the chance of the items in the slot becoming mixed up, and you should be handling all GUIs on the client anyways(not necessary, but a good practice.)

1 Like

The only way I can think of this is to use a remote function?
Player → Clicks on the item in their inventory which fires the server
Server → Obtains the player, captures their inventory and conducts the swap → send player a confirmation the change was made?

Should the inventory capturing be done through the client which sends this information to the server to do the necessary change? Or should the server be capturing the player’s inventory?

My inventory drag/drop system looks something similar to this.

You should actually do it the other way around. The server doesnt really need to know how your inventory looks, and that is the best way to go about making GUIs(apart from timers and stuff), because the client is the only one ever going to be interacting and seeing the GUIs. Whenever you get a new item, you should send a message to the client from the server and from there, the client handles the swap and the layout of the inventory.

1 Like

I’m going to have multiple plant models scattered across the world that the player can pick up, should I have 1 script that handles all of those models for when 1 is clicked? Or should each plant model have it’s own script to check when it’s being clicked → call the client?

1 Like

I am not an expert in performance in games with multiple scripts vs one script, but I think it mainly depends on the amount of objects like these you have.

What I would do is have one master script that controls all the interactions between these objects, just so it is organized, and if I wanted to go back and make changes, I would not have to go into every individual script in each item.

1 Like

I ended up handling the item swap on the client side like you said, and it ended up working way better than expected! I used a remote function to detect player input → confirm on server → once confirmed, the client swaps the two items’ positions. Thank you for helping me solve an issue I’ve been stuck on for a week now!

2 Likes

That’s amazing! I am glad that you have it working, and I wish you the best of luck with your game! :smiley:

2 Likes