Why doesnt this gamepass work

i was trying to make a gamepass door script but it doesnt work

the script is parented to starterplayerscripts

-- 
local VipDoor = game.Workspace.VIPDoor
local player = game.Players.LocalPlayer
local gamepassId = 44709053 --- Change To Your Gamepass ID
local PlayerOwnGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassId)

if PlayerOwnGamepass then
	VipDoor.Transparency = 0.8
	VipDoor.CanCollide = false
else
	VipDoor.Transparency = 0
	VipDoor.CanCollide = true
end
3 Likes
-- 
local VipDoor = game.Workspace.VIPDoor
local player = game.Players.LocalPlayer
local gamepassId = 44709053 --- Change To Your Gamepass ID
local success,error = pcall(function()
    game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassId)
end)

if success then
    print("Player owns gamepass")
	VipDoor.Transparency = 0.8
	VipDoor.CanCollide = false
else
    warn("Player does not own gamepass")
	VipDoor.Transparency = 0
	VipDoor.CanCollide = true
end

Try printing some things, and see what errors you get

thx sry i dont knnow how to make gamepasses at all lol
ill try that script

it seems to make the door cancollide off even when i dont have the gamepass

it also doesnt print anything

Let me remake the code for you. While i’m doing so, I will tell you what you did wrong.

  • MarketPlaceService instead of MarketplaceService

Make sure you spell everything correctly when scripting! Don’t forget the capitals, and etc…


New Code :

Open Me
-- Variables

local VipDoor = game.Workspace.VIPDoor
local Player = game.Players.LocalPlayer

local GamepassId = 44709053
local PlayerId = Player.UserId

----------------------------------------

-- Code

if game:GetService("MarketPlaceService"):UserOwnsGamePassAsync(PlayerId, GamepassId then
	VipDoor.Transparency = 0.8
	VipDoor.CanCollide = false
else
	VipDoor.Transparency = 0
	VipDoor.CanCollide = true
end

Reminder :

If this worked, don’t forget to mark this as the solution.

it doesnt seem to work i put the script in starterplayerscripts is that right?

Have you tried waiting for the block to load in maybe?

Before I try to solve your problem, why did you put the script in StarterPlayer? Shouldn’t it be in a regular script in the door?

You need to use a LocalScript if you want to open the door for one player only. Not a Script.

Then you also need to use WaitForChild() for the door first time you access it, since the workspace needs time to be replicated to the client.

Try using breakpoints and step through the code, line by line. Check the Watches list to see if variables have the values that you expect.

Try cheating if you want to eliminate the gamepass as the problem:

if PlayerOwnGamepass or true then

The print statement is also your friend.

I made a badge today but by accident I pasted the experience Id not the badge Id. :smiley: That did not work, it just failed silently.

1 Like