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

[SOLVED] How do I properly check if a player has a gamepass, nothing I'm trying is working?

Asked by 6 years ago
Edited 6 years ago

So I'm trying to make so when you have a gamepass in my game, you get your exp gain multiplied by 2. When I use

1if passService:PlayerHasPass(player,5429209) then
2 
3end

it prints the error: GamePassId '5429209' is not of type Game Pass. Please use MarketplaceService:PlayerOwnsAsset instead. The first thing I tried was to do it like

1if game.MarketplaceService:PlayerOwnsAsset(player,5429209) then
2 
3end

and it doesn't print an error, but the game doesn't think I own the gamepass, and ignores the if statement.

Script:

01local testers = {"FoxOwO","S_naZY","jurassicsonic","Knineteen19","Black_Xenon","Phoen_ix25","Dragonwizarder","NovaGaming1234","Axiom_Vang"}
02local passService = game:GetService("GamePassService")
03 
04game.Players.PlayerAdded:connect(function(player)
05    player.CharacterAdded:connect(function(char)
06        local multi = script:WaitForChild("XP Multiplier")
07        local multiplier = multi:Clone()
08 
09        if player.Name == "Knineteen19" then
10            multiplier.Value = multiplier.Value * 10
11            print(multiplier.Value)
12        end
13 
14        for i,Testers in pairs(testers) do
15            if Testers == player.Name then
View all 29 lines...

Any help would be appreciated!

1 answer

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

Yea, roblox's new gamepass system is very messed up and dumb. For example GamePassService:PlayerHasPass() will only give you an accurrate result if you use the asset id and not gamepass id of the gamepass. So I honestly don't know why they added that function in the first place.

Another thing about the asset ids and gamepass ids is their api. There are two endpoints for getting the info about the gamepass: the first one takes the gamepass id, the other one takes the asset id. Now, they return the exact same info, with one difference: the first one doesn't return the asset id! It would be very useful if it did, because then you could use it with MarketplaceService:PlayerOwnsAsset().

So, what you need to do is use MarketplaceService:UserOwnsGamePassAsync()

Note that it takes the player's UserId as the first argument, rather than a player object itself.

1if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,5429209) then
2    --stuff
3end

Btw, I just found some "clarification" about this on roblox wiki over here. Though it's still dumb that they hid it under some function documentation.

0
Kind of weird, but it worked. Thanks! Knineteen19 307 — 6y
Ad

Answer this question