Scripting Support Needed

Why is this not prompting the player after 1 second??? No error.

local gamePassId = 111451515
local marketPlaceService = game:GetService("MarketplaceService")
local function promptPurchase()
	
	local hasPass = false
	
	local success, message = pcall(function()
		hasPass = marketPlaceService:UserOwnsGamePassAsync(player.UserId,gamePassId)
	end)
	
	if hasPass == true then
		print("Player already has the gamepass")
		marketPlaceService:PromptGamePassPurchase(player, gamePassId)
	else
		marketPlaceService:PromptGamePassPurchase(player, gamePassId)
	end
end	

local x2Stone = player:WaitForChild("PlayerGui"):WaitForChild("GamepassFrame"):WaitForChild("ScrollingFrame"):WaitForChild("x2Stone")

wait(1)
promptPurchase()

It works fine for me, i made a few modifications tho:

local A = game:GetService("MarketplaceService")

function prompt(p: Player?,gamePass: number?)


	local Success, Pass = pcall(function()
		return A:UserOwnsGamePassAsync(p.UserId,gamePass)
	end)

	
	if Success then
		if Pass then
			print("Yay")
            A:PromptGamePassPurchase(player, gamePass)
		else
			warn("Nay")
            A:PromptGamePassPurchase(player, gamePass)
		end
	end


end

wait(1)
prompt(game.Players.LocalPlayer, 111451515)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.