Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can you get a Game pass and a Game pass door to work?

I've found this code from a Roblox Wiki for the game pass to work, I think it works but I can't get the print command to find an issue. This is the code.

**local passId = 472393458 --change this to your GamePass Id local marketplaceService = game:GetService("MarketplaceService")

marketplaceService.PromptPurchaseFinished:connect(function(player,assetId,isPurchased) if isPurchased then --if the player did pay if assetId == passId then --if what they bought is the pass print(player.Name .. " bought the pass (" .. passId .. ")") end end end)**

I also found a Game pass doors since I am new to scripting, I know that I need to find the 'GamepassID' command yet there isn't one. Here is the script for the door.

Door Model Link: https://www.roblox.com/Game-Pass-VIP-door-item?id=93037753

**-------------------- --| WaitForChild |--

-- Waits for parent.child to exist, then returns it local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end


--| Variables |--

local GamePassService = Game:GetService('GamePassService') local PlayersService = Game:GetService('Players')

local VipDoor = script.Parent

local GamePassIdObject = WaitForChild(script, 'GamePassId')

local JustTouched = {}


--| Functions |--

-- Finds out which side the player is on and teleports them to the other local function TeleportToOtherSide(character, hitPart) local bottomOfDoor = VipDoor.CFrame.p - Vector3.new(0, VipDoor.Size.Y / 2, 0) local inFrontOfDoor = bottomOfDoor + VipDoor.CFrame.lookVector * 3 local behindDoor = bottomOfDoor - VipDoor.CFrame.lookVector * 3

local distanceToFront = (inFrontOfDoor - hitPart.Position).magnitude
local distanceToBack = (behindDoor - hitPart.Position).magnitude
if distanceToFront < distanceToBack then
	character:MoveTo(behindDoor)
else
	character:MoveTo(inFrontOfDoor)
end

end

-- When a player with the game pass touches the door, teleport them to the other side local function OnTouched(otherPart) if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then local player = PlayersService:GetPlayerFromCharacter(otherPart.Parent) if player and not JustTouched[player] then JustTouched[player] = time() if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then TeleportToOtherSide(player.Character, otherPart) end end end end

-- Removes old entries in JustTouched local function RemoveOldTouches() for player, touchTime in pairs(JustTouched) do if time() > touchTime + 0.3 then JustTouched[player] = nil end end end


--| Script Logic |--

VipDoor.Touched:connect(OnTouched)

while true do RemoveOldTouches() wait(1/30) end**

I tested it since I have made the game pass, and it doesn't work, I can't move through the door. Could someone help? Possibly help me fix it or fix it for me?

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.