Hey Everyone, I am currently working on a roblox bedwars game and I am stuck on the chest part. I am wondering if anyone can assist me in developing this chest I am trying to make a chest with a proximity prompt.
Thanks In Advance
This is how I would develop something like this, and my thinking process:
Handle Chest
-
I would add a Folder in the chest model in workspace, where all the items would be stored
-
Whenever an item is added, an Int value is added into the folder, the Name of the int value being the Items name, and the Value being of how much of that item is stored in the chest
-
Whenever a item is taken, the Int value is deleted from folder
-
All of this would happen on the server, not the clients
Handle Gui
-
I would have the Gui stored in replicated storage
-
When the prox prompt is triggered, add the gui to the wanted player. And start the local script
-
Have a loop for every item that already exists, and index and load all the images of each item, based on name, and a text label to store the amount of each item
-
Have the client listen for the folder changes of a ChildAdded or ChildRemoved, and when triggered, reload everything, so they are updated, and no two players take the same item
-
Have the images be Image buttons, and when clicked, connect server via remote event to add item to player by Item Name, and the Amount by the Value. Then remove the IntValue from the folder (from server).
-
Have a If statement, and If ChestGui is in PlayerGui, and a player clicks an item in their inventory, contact the server again via remote events, to add the int value, and changing the name of the int value to be the item’s Name, and the value of the int value being the amount of that one item.
-
When player Exits out of the chest gui, I would delete the Gui from the player’s Gui.
Hope this helps!