Hello, I've recently been trying to script something where I'm creating an area only players with a certain gamepass can access. Looking through some of my old creations, I found a functioning script that only works under the old system of gamepasses having normal IDs. If the player does not have the gamepass, it will teleport them a few blocks back. Could anyone help? Much appreciated, Gabe.
✓ ANSWER ACCEPTED
Block that lets only players with a gamepass through?
1 answer
✓ Accepted answer
It's because of the recent GP change that requires MarketplaceService now. Try putting this script in a part/door. Take out the bottom portion if you don't want the door to kill non-gamepass holding players. You can add your teleport part of the script there if you like.
local door = script.Parent
function open()
door.CanCollide = false
end
function close()
door.CanCollide = true
end
function get_player(part)
for _, player in ipairs(game.Players:GetPlayers()) do
if part:IsDescendantOf(player.Character) then
return player
end
end
end
door.Touched:Connect(function(part)
local player = get_player(part)
local character = player.Character
if not player then return end
local allow = (
game:GetService('MarketplaceService'):UserOwnsGamePassAsync(player.userId, 1234567) -- Paste your game pass id here
)
if allow then
open()
delay(4, close)
else
character.Humanoid.Health = 0
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
You know you don't need a separate function just to toggle a boolean? Using the 'not' keyword can do this for you.
Also the allow variable doesn't need to be formatted like that you can just have it in one line.
Thank you very much! It worked flawlessly. I appreciate your help!
No problem...Ok, thank you incapaz.