How to Show both players Inventories in Trade GUI

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

(This is actually my first post on the forum so please keep note of that)

I’ve been working on a Trading GUI so players can swap items with each other.

I want it so both players who are trading can see each others inventory in the GUI.

  1. What is the issue? Include screenshots / videos if possible!

The issue is I’m not sure how to make it so both players can see the other players inventory who they’re trading with.

(If your confused at all with what I’m trying to portray, for example ( Pet Simulator has a trade system)!

There’s 2 sides of this GUI so both players can view the others inventory.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I browsed the Developer Hub but couldn’t find anything.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Should I share some of my code for you to see? I just want to know if anyone has an idea for a way to make this, Thank you.

How is your inventory system set up? i.e. do you have a folder with inventory item names in it, or some other system?

If you have a folder, simply access it by finding the player you are trading it, then for every child, add a new gui.

local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Guihere")

for i, v in pairs (Folder:GetChildren()) do
   if v:IsA("IntValue") then -- checks if the player has the item in the folder
      gui:WaitForChild(v.Name).Visible = true -- makes it visible
   end
end

That is just example code, you’ll have to adjust it to your system.

Oh Yes. Screenshot 2021-02-02 210332

I’m using a folder inside that player that holds the actual items the player picks up.

I’ll try implementing your sample for my system and see if I can get what I’m hoping for to work.

Yeah, my code is just a small example. The main challenge will be finding the player who you are trading with. This may be accomplished by inserting a stringvalue, then changing it to the player name when trading, then clearing it after trading. Then, when you need to find the player who you are trading with, just do

local string = game.Players.LocalPlayers.StringValue.Value
local TradingPlayer = game.Players.LocalPlayer:WaitForChild(string)

You will have to just keep trying, until you uncover a solution. Best of luck!