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
1 | if passService:PlayerHasPass(player, 5429209 ) then |
2 |
3 | end |
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
1 | if game.MarketplaceService:PlayerOwnsAsset(player, 5429209 ) then |
2 |
3 | end |
and it doesn't print an error, but the game doesn't think I own the gamepass, and ignores the if statement.
Script:
01 | local testers = { "FoxOwO" , "S_naZY" , "jurassicsonic" , "Knineteen19" , "Black_Xenon" , "Phoen_ix25" , "Dragonwizarder" , "NovaGaming1234" , "Axiom_Vang" } |
02 | local passService = game:GetService( "GamePassService" ) |
03 |
04 | game.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 |
Any help would be appreciated!
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.
1 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId, 5429209 ) then |
2 | --stuff |
3 | end |
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.