Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Checking if a player has a gamepass?

Hey! I'm using a script from the Toolbox that I found that is simple and easy. However, I am having trouble getting it to work. I made a few touches so that instead of killing the player it jumps them. Here is the script:

id = 12558121 --Gamepass ID

-- Made by Codes Otaku Channel (Youtube), Edited by ReeseTP

gps = game:GetService("GamePassService")

script.Parent.Changed:connect(function(prop)
	if prop == "Occupant" and script.Parent.Occupant then
		if gps:PlayerHasPass(game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent), id) then
			print("Valid")
		else
			script.Parent.Occupant:ChangeState(Enum.HumanoidStateType.Jumping)
		end
	end
end)

When I sit in the DriveSeat, it prompts me with this in the console:

"GamePassID '12558121' is not of type Game Pass. Please use MarketplaceService:PlayerOwnsAsset instead."

Any help is greatly appreciated!

1 answer

✓ Accepted answer

GamePassService is not a valid service anymore Use MarketplaceService

local id = 123456789 --replace with gamepass id
local gpfc = game.Players:GetPlayerFromCharacterAsync()
local check = game.MarketplaceService:PlayerOwnAsset(gpfc,id)
if check ==true then --this will check if the player has the gamepass
print("Player owns gamepass :"..id) --this will be the output if the player owns the gamepass
else
print("Player doesn't own gamepass : "..id) --same for this
end

This discussion is preserved as it was. New answers, comments, and votes are closed.