This bit of code keeps making it so that when the gui appears with the buttons on it with the price of the users items on the button, only two buttons appear (even if they have more than two t shirts on sale) and the two buttons are always $101 and $176, it never changes no matter who the user is. Any idea whats going on? Thanks and sorry for the long code, but I think you will need it to understand the problem.
local function getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
tshirts = tshirts or {}
cursor = cursor or ""
local requestUrl = baseUrl:format(username, cursor)
local success, result = pcall(function()
return http:GetAsync(requestUrl)
end)
if success then
if result then
local success2, result2 = pcall(function()
return http:JSONDecode(result)
end)
if success2 then
if result2 then
for _, tshirt in ipairs(result2.data) do
table.insert(tshirts, tshirt.id)
end
cursor = result2.nextPageCursor
if cursor then
return getUserGeneratedTShirtsRecursive(username, tshirts, cursor)
else
return tshirts
end
end
else
warn(result)
end
end
else
warn(result)
end
end
local exitButton = loser.PlayerGui.Donation.Frame.Exit
exitButton.MouseButton1Click:Connect(function()
loser.PlayerGui.Donation.Enabled = false
end)
loser.PlayerGui.Donation.Enabled = true -- THIS IS THE PART THAT SHOULD MAKE IT VISIBLE
local username = loser.Name
local winnerName = winner.Name
local userTShirts = getUserGeneratedTShirtsRecursive(winnerName)
local num = (#userTShirts)
print(table.concat(userTShirts, " ")) --1031862 1036727 1031864
game.ReplicatedStorage.RemoteEvent:FireClient(winner)
loser.PlayerGui.Donation.Frame.TextLabel.Text = "Donate to ".. winnerName
local table1 = {}
for i = num, 1, -1 do
local Asset = MarketPlaceService:GetProductInfo(userTShirts[i])
local assetPrice = Asset.PriceInRobux
local assetId = Asset.AssetId
if assetPrice == nil or assetId == nil then
print("Failure")
else
-- Create a new table for each item with the price and id
local item = {price = assetPrice, id = assetId}
-- Insert the item into the table
table.insert(table1, item)
end
-- Create a new table for each item with the price and id
end
table.sort(table1, function(a, b)
return a.price < b.price
end)
for i, item in ipairs(table1 or {}) do
if item then
local price = item.price or "default price"
local id = item.id or "unknown"
local newButton = workspace.DonateButton:Clone()
newButton.Text = price .. " R$"
local id = Instance.new("IntValue", newButton)
id.Value = item.id
newButton.Parent = loser.PlayerGui.Donation.Frame.itemsScroller
else
end
end