So I have a script, but I want it to only work if the player owns a game pass.
01 | local TeleportService = game:GetService( "TeleportService" ) |
02 |
03 | local placeID_ 1 = 0000000000 |
04 |
05 | local function onPartTouch(otherPart) |
06 | local player = game.Players:GetPlayerFromCharacter(otherPart.Parent) |
07 | if player then |
08 | TeleportService:Teleport(placeID_ 1 , player) |
09 | end |
10 | end |
11 | script.Parent.Touched:Connect(onPartTouch) |
Anybody know how to do this?
01 | local TeleportService = game:GetService( "TeleportService" ) |
02 | local MPS = game:GetService( "MarketplaceService" ) |
03 | local gamepass = 0000000 |
04 | local placeID_ 1 = 0000000000 |
05 |
06 | local function onPartTouch(hit) |
07 | local hum = hit.Parent:FindFirstChild( "Humanoid" ) |
08 | if hum then |
09 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
10 | if MPS:UserOwnsGamePassAsync(player.UserId,gamepass) = = true then |
11 | TeleportService:Teleport(placeID_ 1 , player) |
12 | end |
13 | end |
14 | end |
15 | script.Parent.Touched:Connect(onPartTouch) |
pls accept, i have used this concept before.
01 | local ID = 000000000 |
02 | local Game = 00000000000 |
03 |
04 | game.Players.PlayerAdded:Connect( function (p) |
05 | local function touch(hit) |
06 | if game:GetService( "MarketplaceService" ):PlayerOwnsGamePassAsync(p.UserId, ID) then |
07 | game:GetService( "TeleportService" ):Teleport(Game, p) |
08 | else game:GetService( "MarketplaceService" ):PromptGamePassPurchase(p, ID) |
09 | end |
10 | end |
11 | workspace.Part.Touched:Connect(touch) |
12 | end ) |