Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago

Gamepass Id is found within the URL of the Gamepass itself. You can find it if you go to the Gamepass's Page, look at the Search Bar, then copy the last 9 Numbers.

ex. https://www.roblox.com/Ultra-Blazing-VIP-item?id=463012281 463012281 Is the Gamepass Id in this case.

Ad

Answer this question