Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you get if the player owns a gamepass or not?

Asked by
Scaii_0 145
6 years ago
Edited 6 years ago

So when a player enters my game it detects it and checks if they own a pass. I do. However, whenever I go into the game, it says I don't own the pass.

Can anyone tell me why? Do I have to do something with the id; try a different method ect?

My script currently is:

local id = 00 

game.Players.PlayerAdded:connect(function(player)
    wait(1)
    local owns = game:GetService("GamePassService"):PlayerHasPass(player, id) 
    print(player,'owning the pass is', owns)

I've also tried using

game.GetService:("MarketPlaceService"):PlayerOwnsAsset(player, id)

but that also returns false

After this this I have the rest of the script saying

If owns == true then 
--rest of script

Or if I make it:

if owns then 

it just says 'GamepassIDHere' is not a gamepass, please use Marketplaceservice instead

But I still had nothing...

Can anyone help?

2 answers

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

Roblox has recently changed the way gamepasses work. From now on, each gamepass, despite an asset id, has its own gamepass id. For example my gamepass's assetid is 1630420092, but its gamepass id is 4374816. Currently the GamePassService doesn't work for me either, but I found a workaround.

You need to get the assetid of the gamepass, and then use MarketplaceService:PlayerOwnsAsset().

In order to do that, go to the gamepass page, right click, click View Source, hit Ctrl + F, search for data-item-id. This is the assetid of the gamepass which you can use with PlayerOwnsAsset().

Ad
Log in to vote
0
Answered by 5 years ago

The way you require the MarketplaceService is wrong, it should be, like all GetService's, this:

game:GetService('MarketplaceService')

From there you can check for players owning assets, without this correctly formatted, it will not work.

Answer this question