UserOwnsGamepassAsync not detecting?

I had a gamepass that basically gives you double the amount of money. It seemed to work perfectly fine but then I bought it for myself and it wasn’t working.

Script:

local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 29090920

game.ReplicatedStorage.Events.SellGems.OnServerEvent:Connect(function(player)
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.leaderstats.Gems.Value * 10
		print(player.Name.." owns the double coins gamepass") -- this isnt printing
	end
end)

I have looked at various articles, checked the gamepass id, and all that

EDIT:
The remote event is firing because I added an “else” event after this and it fires.’

Also this is a server script:

1 Like

Are there any errors in the output?

And is this in a local script or a server script?

are you sure the remote event is firing? Try adding a print and seeing if it does.

local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 29090920

game.ReplicatedStorage.Events.SellGems.OnServerEvent:Connect(function(player)
print("got")
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.leaderstats.Gems.Value * 10
		print(player.Name.." owns the double coins gamepass") -- this isnt printing
	end
end)
1 Like

Check the console for any errors, as suggested.

There’s a good chance the player’s leaderstats are missing “Coins”/“Gems”.

Please send screenshots of your leaderstats, everything seems to be working fine, please pay attention to these 2 things:

1- You have a working leaderstats.
2- You dont have any parameter in the FireServer() event on the client[ player is automatically there, hence u only need to put it as a argument on the server]

No errors in output or console, server script

1 Like

Please give us screenshot of the FireServer() event - which is on the client

Just tested the script and substituted your gamepassId with one that I own just to confirm and it works fine for me. Just in case, can you confirm that you actually own the gamepass in question? It sounds silly but I’ve made little mistakes like that before. I checked your account and it seems like you don’t own it, although you could be testing on an account that has the gamepass, it’s always good to check.

Other than that, I think the only other potential issue could be that for whatever reason that remote isn’t firing under the assumption you’re not getting any errors.

Okay so it wasn’t on this post becuase I for some reason didn’t think it was important but there was an else statement under the gamepass thing that runs perfectly fine if you don’t own the gamepass

Also I don’t exactly have testing accounts but this isn’t my main account. So I own it but not on this account

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Events.SellGems:FireServer()
end)

Remote event fires, just not the UserOwnsGamepassAsync part

Just so I’m understanding correctly, you are testing this on the account you own the gamepass on correct?

Yes, I tested it on the account I own the gamepass on

Is your leaderstats valid?

Could you show us a screenshot of your leaderstats?