You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make a trading system where people can exchange items. Once you click on an item in your inventory window, you input a number into the textbox below and then you click done to input as an offer. -
What is the issue? Include screenshots / videos if possible!
If you input your first offer, everything is fine and your item is inputed. Every input after then inputs the original offer and the new offer you want to make.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I dont know. i tried to make a debounce but it wont work.
This is the code that is in a module script:
Remotes.InitiateTrade.OnClientEvent:Connect(function (Recipient)
if Player.PlayerGui:FindFirstChild(“TextMessageUI”) == nil then return end
local TradeInitiateFrame = TradeGUIFolder.TradeInitiateFrame:Clone()
local MessageUi = Player.PlayerGui:FindFirstChild(“TextMessageUI”)
TradeInitiateFrame.Parent = MessageUi
local PlayerInventoryDisplay = TradeInitiateFrame:FindFirstChild("PlayerInventoryDisplay")
local PlayerOfferScrollDisplay = TradeInitiateFrame:FindFirstChild("PlayerOffersScrollingFrame")
local RecipientOfferDisplay = TradeInitiateFrame:FindFirstChild("RecipientOffersScrolingFrame")
local QuantityInputBox = TradeInitiateFrame:FindFirstChild("QuantityInput")
local DoneButton = TradeInitiateFrame:FindFirstChild("DoneButton")
local RecipientNameLabel = TradeInitiateFrame:FindFirstChild("RecipientNameLabel")
RecipientNameLabel.Text = Recipient.Name.."'s Offers"
for i, item in ipairs(Player:FindFirstChild("InventoryFolder"):GetChildren()) do
local PlayerInventoryInputLabel = TradeGUIFolder.PlayerInventoryInputLabel:Clone()
PlayerInventoryInputLabel.Parent = PlayerInventoryDisplay
PlayerInventoryInputLabel:FindFirstChild("QuantityLabel").Text = " x"..item.Value
PlayerInventoryInputLabel:FindFirstChild("IngredientNameLabel").Text = item.Name
local IngredientImageLabel = PlayerInventoryInputLabel:FindFirstChild("IngredientImageLabel")
IngredientImageLabel.Image = ItemDictionary[item.Name].Image
local IngredientMaxQuantity = item.Value
TradeGUI.MakeOffer(IngredientImageLabel, QuantityInputBox, DoneButton, PlayerOfferScrollDisplay, Recipient, IngredientMaxQuantity)
end
end)
TradeGUI.MakeOffer = function(ItemInputLabel: ImageButton, QuantityInput: TextBox, PlaceOfferButton: TextButton, PlayerOfferScrollFrame: ScrollingFrame, Recipient, MaxValue: number)
if ItemInputLabel then
local OfferDone = false
if OfferDone == true then return end
ItemInputLabel.MouseButton1Down:Connect(function()
OfferDone = true
local offer = {}
offer["Item Name"] = ItemInputLabel.Parent:FindFirstChild("IngredientNameLabel").Text
print(offer["Item Name"])
print(offer)
QuantityInput.FocusLost:Connect(function(enterPressed)
if enterPressed then
local ItemQuantity = tonumber(QuantityInput.Text)
if ItemQuantity then
offer["Quantity"] = ItemQuantity
print(offer.Quantity)
PlaceOfferButton.MouseButton1Down:Connect(function()
--if ItemQuantity > MaxValue then
-- print(ItemQuantity / MaxValue)
-- QuantityInput.Text = "Insufficient Items"
-- offer = nil
-- return
--end
print(offer)
--Remotes.PlaceOffer:FireServer(offer, Recipient)
local PlayerOfferDisplay = TradeGUIFolder.PlayerOfferDisplayFrame:Clone()
PlayerOfferDisplay.Parent = PlayerOfferScrollFrame
PlayerOfferDisplay:FindFirstChild("QuantityLabel").Text = offer.Quantity
PlayerOfferDisplay:FindFirstChild("IngredientImageLabel").Image = ItemDictionary[offer["Item Name"]].Image
end)
else
QuantityInput.Text = "Invalid Input!"
end
end
end)
end)
OfferDone = false
end
end