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

How to make a gamepass script that when you touch a part you get teleported to another game?

Asked by 4 years ago

Well, i was trying to make a gamepass script that when you touch it, it teleports you to another game i'm still a beginner and i need help.

0
You should probably try the function that teleports you to games, when you touch a part, or click a gui. I'm not setting this as an answer, since I don't know if it works. If it doesn't, follow a tutorial. At least try <3 (no downvoty v.v) 1ov3y0u 51 — 4y
0
ANTI-DOWNVOTEANTI-DOWNVOTEANTI-DOWNVOTEANTI-DOWNVOTEANTI-DOWNVOTEANTI-DOWNVOTEANTI-DOWNVOTEANTI-DOWNVOTE 1ov3y0u 51 — 4y

1 answer

Log in to vote
1
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago

Input a Server Script in ServerScriptService with the following code or refer to the bottom for a better alternative

-- >> Server Script Service
local gamepassID = 000 -- Change to your gamepass ID
local placeID = 000
local TS = game:GetService("TeleportService")
local MS = game:GetService("MarketplaceService")

workspace.Part.Touched:Connect(function(hit) -- On touch event
    if hit.Parent:FindFirstChild("Humanoid") then -- Finds a humanoid if it's a player
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- Sets the player

        if MS:UserOwnsGamePassAsync(plr.UserId, gamepassID) then -- Checks if the player owns the pass
            TS:Teleport(placeID, plr) -- Teleports the player to the place
        end
    end
end)    

-- >> Better alternative
-- Local Script In Starter Gui
local plr = game.Players.LocalPlayer
local MS = game:GetService("MarketplaceService")
local TS = game:GetService("TeleportService")
local passID = 000
local placeID = 000

workspace.Part.Touched:Connect(function(hit) -- On touch event
    if MS:UserOwnsGamePassAsync(plr.UserId, passID) then -- Checks if the player owns the pass
        TS:Teleport(placeID, plr) -- Teleports the player to the place
    end
end)
0
-1 for spoonfeeding programmerHere 371 — 4y
0
+1 for helping out the guy out Tyler090130 619 — 4y
Ad

Answer this question