MarketplaceService:UserOwnsGamePassAsync() not returning true even though I own the gamepass

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to fix UserOwnsGamePassAsync not giving me true even though I have the gamepass.

  1. What is the issue? Include screenshots / videos if possible!

Title, and when I created the gamepass, I was automatically given it as the group owner.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried looking on the developer forums, however none of them had a solution I could use.

This is like the code I’m using (Server Script):

local Enabled = false

RemoteEvent.OnServerEvent:Connect(function(Player)
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamepassID) == true then
		if Enabled == false then
			Button.Text = "On"
			Enabled = true
		else
			Button.Text = "Off"
			Enabled = false	
		end
	end
end)
2 Likes

You can use a pcall function and check “if success then” and then continue your script.

1 Like

This will also work:

local mps = game:GetService("MarketplaceService")
local owns = mps:UserOwnsGamePassAsync(plr.UserId, GamepassID)
if owns == true then
	if Enabled == false then
		Button.Text = "On"
		Enabled = true
	else
		Button.Text = "Off"
		Enabled = false	
	end
end
1 Like

Unfortunately this didn’t solve my problem, and for clarification this error happens when I try to buy the gamepass… if I don’t own the gamepass according to UserOwnsGamePassAsync then why does this error say I have it… so confusing

image

Is the RemoteEvent being fired?

Fire a remote event and receive it on a local script, then put whats in your normal script. I don’t know if you can do that from a normal script,

I haven’t looked this through thoroughly yet, but could you add a print statement/debugging statement checking if it’s true/false/nil? It could help with debugging.

The remote event is being fired, this is confirmed by me being prompted the gamepass buy.
(I cut out the part in the code as I thought it wouldn’t be important)

This is my updated code:

RemoteEvent.OnServerEvent:Connect(function(Player)
	
	local HasGamepass = false
	
	local got,err = pcall(function()
		HasGamepass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamepassID)
	end)
	
	if HasGamepass then
		if Enabled == false then
			Button.Text = "On"
			Enabled = true
		else
			Button.Text = "Off"
			Enabled = false	
		end
	else
		MarketplaceService:PromptPurchase(Player,GamepassID,true)
	end
end)

Yeah its returning only false… maybe a studio bug?

Again, I made the gamepass and I automatically got it so maybe that might have something to do with it?
image

Try calling a FireClient event and OnClientEvent in a local script. Then do the code you started with.

When you make the gamepass you will own it for free

Weird, I reckon it could be a studio bug, try reloading studio OR check if the gamepass is properly configured/the id is correct

The gamepass id is 92831110727963, was I supposed to copy the id at the top or the asset id?

Ah… I was supposed to use the id at the top… not the asset id… :expressionless: now it works
Thanks for helping me reach the solution, I appreciate it a lot

1 Like