MarkeplaceService:UserOwnsGamePassAsync Returns false even when the gamepass is purchased

You could set an attribute to the player when the gamepass is bought, and instead of checking with the MarketPlaceService:UserOwnsGamePassAsync() use an attribute. Here is an example that you could try using.

local Tool = script.Parent
local Player = Tool.Parent.Parent
local Humanoid = Player.Character.Humanoid
local Pass = 123123 -- For demo purposes
local MarketplaceService = game:GetService("MarketplaceService")

local GamepassAttributeName = "HasToolGamepass" --/// Change it to any name you like, should be a boolean attribute

Tool.Equipped:Connect(function()
	if Player:GetAttribute(GamepassAttributeName) == true then
		Humanoid.WalkSpeed += 14
	else
		Tool:Destroy()
	end
end)

Tool.Unequipped:Connect(function()
	Humanoid.WalkSpeed -= 14
end)

Now, all you have to do is add this attribute in two cases:

  1. When the player joins and has the gamepass

  2. When the player buys the gamepass

  3. If you already have a script that checks when a player join, add the UserOwnsGamePassAsync check into it, and add the attribute if it returns true. It could look like this

local Pass = 123123 -- /// Change this to the actual gamepass id
local GamepassAttributeName = "HasToolGamepass" --/// Change it to any name you like, should be a boolean attribute

game.Players.PlayerAdded:Connect(function(Player: Player)
     if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, Pass) == true then
         Player:SetAttribute(GamepassAttributeName, true)
     end
end)
  1. When a player buys the gamepass, you should detect it by using the marketplace method " PromptGamePassPurchaseFinished"
local Pass = 123123 -- /// Change this to the actual gamepass id
local GamepassAttributeName = "HasToolGamepass" --/// Change it to any name you like, should be a boolean attribute

local function onGamepassPurchaseFinished(Player: Player, GamepassID: number, WasPurchased: boolean)

   if GamepassID == Pass and WasPurchased == true then
      Player:SetAttribute(GamepassAttributeName, true)
   end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onGamepassPurchaseFinished)

Hope this helps!
If you want to read more, here is the method for purchase finished

Edit: Forgot to add something on the last snippet, should be fixed now

3 Likes