Help on Gamepass Door Script

Im currently searching for gamepass door scripts but havent found any.
I have tried out different gamepass door scripts on the toolbox and youtube but it doesn’t work.

This is how my Gamepass door currently looks like on the explorer.
image

1 Like

LocalScript
BasePart.CanCollide
MarketPlaceService:UserOwnsGamePassAsync
Player.UserId
Workspace.Part instead script.Parent.

1 Like

Hey there, Ammar. This is what your code should look like.

local door = game.Workspace.GamepassDoor.Door
local ID = --Insert Your Id
local marketplaceservice = game:GetService("MarketplaceService")

door.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if humanoid then
if marketplaceservice:UserOwnsGamePassAsync(player.UserId, ID) then
   door.CanCollide = true
   door.Transparency = 1
    wait(1)
   door.CanCollide = false
   door.Transparency = 0
else
   humanoid.Health = 0
end
end
end)

I hope this helps!!!

2 Likes

There’s a very easy way you can accomplish this, by changing the door’s properties client sidedly

-- LocalScript in StarterPlayerScripts

local MarketplaceService = game:GetService('MarketplaceService')
local Player = game:GetService('Players').LocalPlayer
local passId = 0 -- The gamepass ID

if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,passId) then
    print('Player owns pass')
    workspace.GamepassDoor.Door.CanCollide = false
end

This will prevent other players from entering the door if 2 clients enter at the same time (one with and one without the gamepass). Having it server-sided could accidentally allow unintended players from passing.

3 Likes

Its Easy! Here You Go This Is What The Script Should Look Like.

local Door = game.Workspace.GamepassDoor.Door -- Location of Door
local DoorGamepass = -- Put Your Gamepass Id
local Market = game:GetService("MarketplaceService")

Door.Touched:Connect(function(hit)
local Hum = hit.Parent:FindFirstChild("Humanoid")
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Hum then
if Market:UserOwnsGamepassAsync(player.UserId, DoorGamepass) then
Door.CanColide = false 
wait(1)
Door.CanColide = true
else
Hum.Health = 0
   end
end
2 Likes

So many replies! Thank you yall for helping me.

1 Like

No Problem! Mark any one As a Solution If It Helped You.