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

How do get if a player owns a gamepass / prompt game pass from a localscript?

The ID is 1405452320 and I've already tried this:

--> Local Script
script.Parent.Changed:connect(function()
	if not isVis and script.Parent.Visible then
		isVis = true
		if script.Parent.remote:InvokeServer() then
			if enabled.Value then
				sf("Info")
				page = 0
			else
				sf("Disabled")
			end
			script.Parent.PageNum.Text = "---"
		else
			--script.Parent.Disabled.Visible = true
			--/\ remove that comment when ready
			script.Parent.remote:InvokeServer(true)
		end
	elseif not script.Parent.Visible then
		isVis = false
	end
end)
--> Script (under same parent as localscript, and remote is a RemoteFunction)
script.Parent.remote.OnServerInvoke = (function(p,purchase)
	if purchase then
		game.MarketplaceService:PromptGamePassPurchase(p,1405452320)
	else
		return game.GamePassService:PlayerHasPass(p,1405452320)
	end
end)

Filtering is not enabled, so despite my bad practice, it should still work.

1 answer

Instead Try doing this:

Note: Player is game.Player.LocalPlayer

local owns = game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 1405452320)
				if owns == true then -- If player owns gamepass
--Action
else -- If player does not own gamepass
-- Action
end

Also note, this wont work in studio. You actually have to play it in your real game. PlayerOwnsAsset is something you can use. If this worked please mark as answered.

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