Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How does marketplace service work?

local id = 4426173


script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if game.MarketplaceService:PlayerOwnsAsset(player,id) then
		local gui = game.ServerStorage.GUI.GPGui:Clone()
		gui.Parent = player.PlayerGui
	else
		game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
	end
end)

This is supposed to check if the player owns the gamepass and if they don't it will prompt them but it keeps prompting me in studio even if I own it.

1 answer

Roblox is very messy when it comes to working with MarketPlaceService: you have to use UserOwnsGamePassAsync() instead of PlayerOwnsAsset() when working with gamepasses.

Like this:

local id = 4426173


script.Parent.ClickDetector.MouseClick:Connect(function(player)
    if game.MarketplaceService:UserOwnsGamePassAsync(player.UserId,id) then
        local gui = game.ServerStorage.GUI.GPGui:Clone()
        gui.Parent = player.PlayerGui
    else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.