Help with Gamepass Door

For some reason, all of the Gamepass Door script tutorials just stopped working.


This is the script I’ve used, and for some reason, it doesn’t work.

I want a simple gamepass door script, so if you have the gamepass you can go through. I don’t want the player to be killed or anything special.

1 Like

Are there any errors? Are you sure that you have the gamepass?

This is the only error. I do have the gamepass.

It seems to be in a server script. game.Players.LocalPlayer has to be called from a local script
Try moving the script to a local script

2 Likes

You’re using a Server script (I assume), and a Server Script doesn’t know what “LocalPlayer” is.

Make a Script in ServerScriptService and read more down below.

Here’s how to fix your code.

local Players = game:GetService("Players") -- Get the Players Service
local MarketplaceService = game:GetService("MarketplaceService") -- Get the MarketplaceService Service
local Workspace = game:GetService("Workspace") -- Get the Workspace Service

local GamepassID = 0000000 -- Replace the 0000000 with your Gamepass ID

Players.PlayerAdded:Connect(function(Player) -- Waiting for the player to join and giving it a variable called "Player".
    Player.CharacterAdded:Connect(function(Character) -- Waiting for the " Player "'s Character.
        if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then -- We're using the MarketplaceService Service to check whether the Player owns the gamepass, by using their UserId, as gamepass purchases are always stored on a Player's USERID. You don't have to add a " == true ", using this will already check if you own it, if yes, you can continue code, if not, you don't have to do anything.
            -- Player owns the Gamepass:
            Workspace:FindFirstChild("HelicopterDoor"):Destroy() -- You don't have to make it invisible and cancollide off, "Destroying" the part will do the exact same. 
        end -- End of function "MarketplaceService"
    end) -- End of function "Character"
end) -- End of function "Player"

Hope this helps, I guess?

If you were to destroy something with a server script, it will replicate across the entire server. Basically meaning if someone with the gamepass joins, everyone will be able to go into the area with the gamepass door. Also, you don’t need to get workspace with game:GetService('Workspace') you can just use workspace.

Whoops, you’re right. Might as well fire a remote event and destroy it on the client.