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

How do I make a part that teleports you when you step on it?

Asked by 5 years ago

I have a game that when you go through the door it teleports you to the desired game, any help?

2 answers

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

For teleport players to another game you need to use the TeleportService.

Is here in the wiki: TeleportService - Wiki --- TeleportService:Teleport - Wiki

For first, create a ServerScript in your part and put this script:

local place_id = 0 -- Place to teleport

script.Parent.Touched:Connect(function(hit) -- On touch in part
    if hit.Parent:FindFirstChild("Humanoid") then -- Try to find humanoid in hit.Parent / try to find humanoid in player character
        local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- or you can use game:GetService("Players"):FindFirstChild(hit.Parent.Name)
        if player then -- If find the player
            game:GetService("TeleportService"):Teleport(place_id,player) -- Teleport player.
        end
    end 
end)

Hope it helped :D

Errors? tell-me on comments.

0
Why can't I accept the answer? Yosufgamer -7 — 5y
0
Because negative reputation. LoganboyInCO 150 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This is quite a simple task if you are familiar with the games "services". One of these services is the teleporting service. This is what service you have to call to make any request that involves moving a player from place to place.

To accomplish this task add a script to the part you want to teleport the player with. The script should look like this:

local placeId = -- id of the place you want to teleport them to

local TeleportService = game:GetService("TeleportService") -- getting the teleport service
script.Parent.Touched:Connect(function(hit) -- this fires every time the object is touched
    local h = hit.Parent:FindFirstChild("Humanoid") -- making sure a player touched it
    if h then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- getting the player
        TeleportService:Teleport(placeId, player) -- teleporting the player
    end
end)

Hope I helped

-Cmgtotalyawesome

Answer this question