How to show bought passes in in-game inventory

Hi, im trying to make an in-game inventory which will show the passes which player have bought.
I’ve tried following an Inventory tutorial then adding ‘if player has pass’ then show the item in inventory but it doesnt work. Googled everywhere and cant find a tutorial to show what im after, all just show player backpack items not bought items.


local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")

local RainbowpassID = 86294878

local ItemFrame = script.Parent:FindFirstChild("ScrollingFrame")


local Trail = game.ServerStorage["RainbowTrail"]

local image = script.Parent.Frame.ScrollingFrame.Sample


Players.PlayerAdded:Connect(function(player)

	player.CharacterAdded:Connect(function(character) -- This was needed

		local success, hasPass = pcall(function() -- Changing the pcall to the correct format
			return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, RainbowpassID)
		end)

		if success then -- Checking if successful
			if hasPass then -- Checking if the player has the
				
				local ItemButton = ItemFrame:FindFirstChild("Sample"):Clone()
				
				ItemButton.Visible = true
				
				ItemButton.Parent = ItemFrame
				
				image = "rbxassetid://10939860799"
				
				
				end
				
			end

		end)

end)

Heres the script im using. It checks whether they have bought “rainbowpass” and if they do it should display into the inventory and showthe image of rainbowpass too!

Anyone know how to help? I’d appreciate it! Thankyou

My Idea is after the player buys a Pass set a Variable to true, If u want to check which passes a player has bought just check all the gamepass variables, If its true display it, If false dont display it


local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")

local RainbowpassID = 86294878

local ItemFrame = script.Parent.Frame.ScrollingFrame


local Trail = game.ServerStorage["RainbowTrail"]

local rainbowbuy = false



Players.PlayerAdded:Connect(function(player)

	player.CharacterAdded:Connect(function(character) -- This was needed

		local success, hasPass = pcall(function() -- Changing the pcall to the correct format
			return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, RainbowpassID)
		end)

		if success then -- Checking if successful
			if hasPass then -- Checking if the player has the
				
				rainbowbuy = true
				
				
				
			end
				
			end

		end)

end)


if rainbowbuy == true then
	
	local clone = script.Parent.Frame.ScrollingFrame.ImageLabel:Clone()
	
	clone.Visible = true
	
	
	
	
end

Is this what you mean? The script still doesnt work as it doesnt want to show the new clone of the sample inventory item.