Checking For Gamepasses

How do I check if a player owns a gamepass? I’ve tried putting stuff like local ownsGamepass = game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId,13162459) and if ownsGamepass == true then… but it is still not working. This probably is simple because so many people us it but I just haven’t been taught yet.

1 Like

Shouldn’t you be using a function?

1 Like

Is it by any chance because roblox is down? Wait wdym using a function?

1 Like

Wdym using a function? I put a if statement to check if it is true…

1 Like

I mean something like this:

local MPS = game:GetService("MarketplaceService")

local function CheckForPass(plrId, passID) -- plrId is the Player ID and passId is the Gamepass ID
	if MPS:UserOwnsGamePassAsync(plrId, passID) then
		-- Do Stuff
	end
end

CheckForPass(0, 0)
1 Like

can you give us the full script
Edit do you have the gamepass id correct?

2 Likes

Yes I do. Here is the full script. local pad = script.Parent

local teleportTo = game.Workspace.CityMap.GoToCity

local MarketPlaceService = game:GetService(“MarketplaceService”)

pad.Touched:Connect(function(hit)

local Name = hit.Parent.Parent.Name
print(Name)
if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
end
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)



print(player.UserId)


	if player.leaderstats.Berries.Value >= 0 then

		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		if humanoid then
			local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
			if humanoidRoot then
				humanoidRoot.CFrame = teleportTo.CFrame
			end
		end
	end
end)
2 Likes

So should i make it
local pad = script.Parent

local teleportTo = game.Workspace.CityMap.GoToCity

local pad = script.Parent

local teleportTo = game.Workspace.CityMap.GoToCity

local MarketPlaceService = game:GetService(“MarketplaceService”)

pad.Touched:Connect(function(hit)

local Name = hit.Parent.Parent.Name
print(Name)
if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
end
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

local function CheckForPass(plrId, 13162459) -- plrId is the Player ID and passId is the Gamepass ID
	if MPS:UserOwnsGamePassAsync(plrId, 13162459) then
		if player.leaderstats.Berries.Value >= 0 then

			local humanoid = hit.Parent:FindFirstChild("Humanoid")
			if humanoid then
				local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
				if humanoidRoot then
					humanoidRoot.CFrame = teleportTo.CFrame
					end
				end
			end
		end)
	end
end
1 Like

Or something like that? Cause the second one is erroring the line that is saying – plrId is the…

1 Like

Yo you there? M8 if you don’t know what to do that’s all good just tell me. If you could help that would be really helpful lol

I think this is a ROBLOX problem.

2 Likes

Wait not lying? COMN ROBLOX! argg.

I thought this had something to with the script but it Roblox error…

i original was going to rewrite you a new script but nevermind I guess.

the script
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local teleportTo = game.Workspace.Part
local pad = script.Parent

local gamepassid = 11849405

local function Touched(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId,gamepassid) then
		local Folder = player:WaitForChild("leaderstats")
		local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
		local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
		if Folder.Berries.Value >= 0 then
			if Humanoid and humanoidRoot then
				humanoidRoot.CFrame = teleportTo.CFrame
			end
		end
	end
end

pad.Touched:Connect(Touched)
1 Like

No please could you write me a new script?!

Please static. That would be really helpful! Thank you.

Here use this, you can make this a script or simply run it in console.

local plr = game.Players.PlayerNameHere
local PassId = 13162459
if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(plr.UserId,PassId) then
print(plr.Name.." Owns This Gamepass!")
else
print(plr.Name.." Does Not Own This Gamepass!")
end

Hope you find this useful.

2 Likes

Wait will that actually work? If so thank you so much! Idk why I couldn’t find this anywhere…

yes this will 100% work!
here is a script that can work when the player joins!

game.Players.PlayerAdded:Connect(function(plr)
local PassId = 13162459
if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(plr.UserId,PassId) then
print(plr.Name.." Owns This Gamepass!")
else
print(plr.Name.." Does Not Own This Gamepass!")
end
end)
1 Like

Yo thank you so much! If dev forum wouldn’t report me for using all caps I would! This is literally EVERYTHING I was looking for! Thanks again! :smiley: