GamepassService awarding function?

So, I recently came across someone in a game I work for that does not have a purchasable badge.
I cant find a function of GamepassService to give someone a gamepass for free. That is what I am looking for.

1 Like

Gamepass system is deprecated I’m pretty sure and is used for the old gamepasses.

You should use MarketplaceService for anything to do with gamepasses, but from what I know, you can’t give someone gamepasses for free.

Sorry I did mean to say MarketPlaceService

There’s no functions that allow you to give gamepasses for free, the only thing you can do to “give it for free” is to get the person’s userid who you want to allow the gamepass to for free and where you check if they own the gamepass, check if their userid is the same

Example

if player.UserId == 15467478 or MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
    -- gamepass code
end

If you have more than 1 person you want to do this to, put the ids in a table and check if the id in the table

Well its a good idea, but I can’t update the game with unfinished work, but that’s fine, thankyou.

1 Like

Hey , why not use this instead?

local success,result  = pcall(function()
     return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)
end)

is success  then
    if result or player.UserId == 15467478 then --if he owns the pass, or the id of that player is ..
         --do code
    end
end

Better yet, perform the ID check beforehand, as it’s less intensive than a network call. An underlying optimisation taken by Lua is that it ignores parts of Boolean expressions it doesn’t need to evaluate.

local Game = game

local Whitelist = {
	[1] = true,
	Game.CreatorId = true
}

if Whitelist[Player.UserId] or Condition then --Whatever 'Condition' is replaced by is only checked if the previous part of the expression evaluates to false.
	
end