I am making a trading system. I will explain how it works
Player clicks another player is a list of tradeable players and that requested player gets the trade request
Once they click accept both of the traders will be shown the TradingGui.
The player has 3 different inventory types to select a trade from. Banner Icon, Emote & Victory Theme. There is a button in the Gui which will send a remote event to the server containing
InventoryTypebutton the player clicked on. For example, Emote Button.The server will go to the Player's inventory and try to find a folder named the same as the emote button. When it finds the Emote Folder it will create a table called
PlayerInventory. It will loop through the players emotes. It will also create another table calledInventoryDataSpot, which will save all values parented by that emote. (EmoteName, Quantity, Image, Rarity).
An InventoryDataSpot table should look like this.
(This is not the problem)
local InventoryDataSpot = {}--Makes table
local IDS_Background = Templates.RarityBackgrounds[InventoryItemInInventoryType.Rarity.Value].Image --Saves Rarity Image
local IDS_Name = InventoryItem.Name --Saves Name
local IDS_Title = InventoryItem.Name --Saves Name again
local IDS_ItemPicture = InventoryItemInInventoryType.Image --saves image of the requested item
local IDS_Amount = InventoryItem.Quantity.Value--Saves the amount of the item the player owns
--inserts all of the saved variables into IDS
table.insert(InventoryDataSpot,IDS_Background)
table.insert(InventoryDataSpot,IDS_Name)
table.insert(InventoryDataSpot,IDS_Title)
table.insert(InventoryDataSpot,IDS_ItemPicture)
table.insert(InventoryDataSpot,IDS_Amount)
--IDS then is saved to the PlayerInventory
table.insert(PlayerInventory,InventoryDataSpot)
print("Added",InventoryItem.Name,"to PlayerInventory")
5)The server will return the PlayerInventory table back to the player in a remote event. This is where the problem starts. The client will receive the table and will clone a FrameGui saved in replicated storage to store all the information in.
Here is how it is coded, It should be fairly easy to read:
for i = 1,#PlayerInventory do
print("creating the frames")
local IDS_Background = PlayerInventory[i][1]
local IDS_Name = PlayerInventory[i][2]
local IDS_Title = PlayerInventory[i][3]
local IDS_ItemPicture = PlayerInventory[i][4]
local IDS_Amount = PlayerInventory[i][5]
local NewInventoryFrame = Templates.InventoryItemFrameTemplate:Clone()
NewInventoryFrame.Background.Image = IDS_Background
NewInventoryFrame.Name = IDS_Name
NewInventoryFrame.Title.Text = IDS_Title
NewInventoryFrame.ItemPicture.Image = IDS_ItemPicture
NewInventoryFrame.Amount.Text = IDS_Amount
NewInventoryFrame.Parent = Frame.TradeFrame.InventoryShowcase.ScrollingFrame --will display the item inside the scrollingframe
if IDS_Amount > 1 then--If it the player has more than one
NewInventoryFrame.Amount.Visible = true --it will show how much of it the player owns
end
end
Now, after that is ran, the client will then create a function for a TextButton called ClickBox. Yes. It's called ClickBox and not ClickButton. It is still a TextButton. I'm 100% sure. ClickBox is inside the frame that is being cloned. The player should be able to click it as it should appear inside the ScrollingFrame.
This script runs in the next line of the one above. The frames should have been added to the ScrollingFrame, so it will loop through it. The code continues to work. There are no errors printed.
for i,InventoryFrame in pairs(Frame.TradeFrame.InventoryShowcase.ScrollingFrame:GetChildren())do
if InventoryFrame:IsA("Frame")then--If it is a frame. Yes. The cloned frame is a Frame class
InventoryFrame.ClickBox.MouseButton1Click:Connect(function()--PROBLEM
print("FOUND CLICK")
for i,Slot in pairs(TradingGui.Values.TradingSlots:GetChildren())do--it will go through all trading slots
print("IN SLOT FOR LOOP")
if Slot.Value == "" then--if the slot isnt occupied
print("SLOT EQUALS NOTHING.")
Slot.Value = InventoryFrame.Name--changes slot value to the item name
print("VALUE IS NOW",InventoryFrame.Name)
ReplicatedStorage.RemoteEvents.C2S.ChangePartnerTradingSlot(Slot.Name,InventoryFrame.Name, TradingGui.Values.TradingPartner.Value, TradingGui.Values.InventoryType.Value)
print("SENT RE")
break
else
print(Slot.Name,"is occupied")
end
end
end)
end
end
There is some extra code in the mouse button1click. And none of the prints show. Meaning the "FOUND CLICK" does not show which indicates that it is not reading the mousebutton1click.
I hope someone could lend a hand on how or why it's failing to detect the click.
