local GamepassId = 0000000
script.Parent.MouseButton1Click:Connect(function()
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamepassId) then
game.Players.LocalPlayer.character.Torso.CFrame = CFrame.new (2.1, 6.46, 272.15)
end
end)
Here is a working script:
Local script in gui to prompt the purchase:
local Button = script.Parent.TextButton
local GamePassId = 10503628
local MarketPlaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function()
MarketPlaceService:PromptGamePassPurchase(Player, GamePassId)
end)
Script inside of part with the click detector:
local MarketPlaceService = game:GetService("MarketplaceService")
local OwnsPass = false
local GamePassId = 10503628
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local success, message = pcall(function()
OwnsPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId)
end)
if OwnsPass == true then
player.Character.HumanoidRootPart.Position = Vector3.new(0,10,0)
else
print("You dont have the game pass")
end
end)
It will teleport you because you own the gamepass, but you can start a local server to see what when you don’t own it
local Button = script.Parent.TextButton
local GamePassId = 00000
local MarketPlaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function()
MarketPlaceService:PromptGamePassPurchase(Player, GamePassId)
end)
local MarketPlaceService = game:GetService("MarketplaceService")
local OwnsPass = false
local GamePassId = 10503628
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local success, message = pcall(function()
OwnsPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId)
end)
if OwnsPass == true then
player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(0,10,0))
else
print("You dont have the game pass")
end
end)
That is a fixed version setting the CFrame of the character.
local ClickDetector = script.Parent
local GamepassId = 0
local TeleportLocation = CFrame.new(2.1, 6.46, 272.15)
local PromptPurchaseIfNotOwned = true
ClickDetector.MouseClick:Connect(function(Player)
if script.ClassName == "LocalScript" then return end
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamepassId) then
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
if PlayerCharacter then
if PlayerCharacter:FindFirstChild("HumanoidRootPart") ~= nil then
PlayerCharacter:FindFirstChild("HumanoidRootPart").CFrame = TeleportLocation
end
end
else
if PromptPurchaseIfNotOwned then game:GetService("MarketplaceService"):PromptGamePassPurchase(Player, GamepassId) end
end
end)
local MarketPlaceService = game:GetService("MarketplaceService")
local OwnsPass = false
local GamePassId = 10503628
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local success, message = pcall(function()
OwnsPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId)
end)
if OwnsPass == true then
player.Character.HumanoidRootPart.CFrame = CFrame.new(0,10,01)
else
print("You dont have the game pass")
end
end)local MarketPlaceService = game:GetService("MarketplaceService")
local OwnsPass = false
local GamePassId = 10503628
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local success, message = pcall(function()
OwnsPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamePassId)
end)
if OwnsPass == true then
player.Character.HumanoidRootPart.CFrame = CFrame.new(0,10,01)
else
print("You dont have the game pass")
end
end)