So I have a script, but I want it to only work if the player owns a game pass.
local TeleportService = game:GetService("TeleportService") local placeID_1 = 0000000000 local function onPartTouch(otherPart) local player = game.Players:GetPlayerFromCharacter(otherPart.Parent) if player then TeleportService:Teleport(placeID_1, player) end end script.Parent.Touched:Connect(onPartTouch)
Anybody know how to do this?
local TeleportService = game:GetService("TeleportService") local MPS = game:GetService("MarketplaceService") local gamepass = 0000000 local placeID_1 = 0000000000 local function onPartTouch(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if MPS:UserOwnsGamePassAsync(player.UserId,gamepass) == true then TeleportService:Teleport(placeID_1, player) end end end script.Parent.Touched:Connect(onPartTouch)
pls accept, i have used this concept before.
local ID = 000000000 local Game = 00000000000 game.Players.PlayerAdded:Connect(function(p) local function touch(hit) if game:GetService("MarketplaceService"):PlayerOwnsGamePassAsync(p.UserId, ID) then game:GetService("TeleportService"):Teleport(Game, p) else game:GetService("MarketplaceService"):PromptGamePassPurchase(p, ID) end end workspace.Part.Touched:Connect(touch) end)