One of my gamepass is having problem when taking to NPC

The window of purchasing the item on gamepass isn’t appearing when I talk to a NPC.

The script:

local marketplaceService = game:GetService("MarketplaceService")

local player = game.Players.LocalPlayer

local lemonadeID = 31563881

script.Parent.ProximityPrompt.Triggered:Connect(function()
	wait(2)
	local success, message = pcall(function()
		local hasPass = marketplaceService:UserOwnsGamePassAsync(player.UserId, lemonadeID)

		if hasPass then
			print("Player already have this gamepass")
		else
			marketplaceService:PromptGamePassPurchase(player, lemonadeID)
		end
	end)
end)
local marketplaceService = game:GetService("MarketplaceService")



local lemonadeID = 31563881

local prompt = script.Parent


prompt.Triggered:Connect(function(player)
	if not marketplaceService:UserOwnsGamePassAsync(player.UserId,lemonadeID) then
		marketplaceService:PromptGamePassPurchase(player,lemonadeID)
	else
		print(player.Name.."Already owns gamepass")
	end
end)

Try this

1 Like