In my game, I am trying to make a 'VIP Door' which will need the player to buy a gamepass so they can teleport to another place. I have put the place in 'Other Places' on the roblox website and put the following code in a script inside the 'Door':
local passId = 622740681 local marketplaceService = game:GetService("MarketplaceService") function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then marketplaceService.PromptPurchaseFinished:connect(function(player,assetId,isPurchased) if isPurchased then if assetId == passId then game.GetService("TeleportService"):Teleport(623097807, player) end end end) end end script.Parent.Touched:connect(onTouched)
If you can see, I used some help from the roblox wiki, but I can't get it to work.
Found a solution!
local passId = 000000000 -- change this to the game pass ID. function authenticate(player) return game:GetService("GamePassService"):PlayerHasPass(player, passId) end script.Parent.Touched:connect(function(hit) if game.Players:FindFirstChild(hit.Parent.Name) then if authenticate(game.Players[hit.Parent.Name]) then local player = game.Players:GetPlayerFromCharacter(hit.Parent) game:GetService("TeleportService"):Teleport(00000000, player) -- Change the 0s to your 'other game' id end end end)