Pls Donate style donation system not displaying gamepasses correctly?

I’m trying to make a stand that shows that gamepasses a player has (only gamepasses for now)
However, it prints the right amount of gamepasses, but still clones like 3 times the correct amount.

script.Parent.Triggered:Connect(function(plr)
	script.Parent.Parent.Parent.NamePart.NameGui.NameLabel.Text = plr.Name
	local gamepasstable = getUserCreatedGamepassesRecursive(plr.UserId)
	print(#gamepasstable)
	for i = 1, #gamepasstable do
		local count = 0
		count += 1
		print(count)
		print("ran")
		pcall(function()
			--print(v)
			local productinfo = market:GetProductInfo(gamepasstable[i], Enum.InfoType.GamePass)
			local gamepassbutton = script.Parent.Parent.Parent.ItemsPart.ItemsGui.ItemsScroller.GamepassButton:Clone()
			gamepassbutton.Parent = script.Parent.Parent.Parent.ItemsPart.ItemsGui.ItemsScroller
			gamepassbutton.Text = productinfo.PriceInRobux
			print(gamepasstable[i])
			gamepassbutton.GamepassID.Value = tostring(gamepasstable[i])
			--print(productinfo.PriceInRobux)
		end)
	end
end)

Correction, it does not print the right amount, it says I have 9 gamepasses, while I have 2.
It only shows 2 gamepass ID’s, then it just pastes the same ones over and over again

Note: This is the function I used, I got it from another devforum post, which seemed like it worked

local function getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
	gamepasses = gamepasses or {}
	pageNumber = pageNumber or 1
	lastLength = lastLength or math.huge

	local requestUrl = baseUrl:format(pageNumber, userId)
	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 _, gamepass in ipairs(result2.Data.Items) do
						if gamepass.Creator.Id == userId then
							table.insert(gamepasses, gamepass.Item.AssetId)
						end
					end

					if result:len() ~= lastLength then
						lastLength = result:len()
						pageNumber += 1
						getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
					end
				end
			else
				warn(result)
				getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
			end
		end
	else
		warn(result)
		getUserCreatedGamepassesRecursive(userId, gamepasses, pageNumber, lastLength)
	end
	return gamepasses
end
1 Like