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

I want to make a teleporter, but how?

Asked by 7 years ago

I want to teleport players to another area in my game, but I don't know how. I need an example of Lua that will teleport people to the place I want. Thanks!

-Infina

2 answers

Log in to vote
0
Answered by
itsJooJoo 195
7 years ago

Say for an example, you put a part into workspace, you'd put this script inside it:

local debounce = false
local coordinates = 0, 0, 0 --These are (in order) the XYZ coordinates to teleport to. Change it to what you like

script.Parent.Touched:connect(function(hit)
    if not debounce then
        if hit.Parent.Torso and hit.Parent.Humanoid then
            hit.Parent.Torso.CFrame = CFrame.new(coordinates)
            debounce = true
            wait(4)
            debounce = false
        end
    end
end)

This uses CFrame and Debounce to help optimize this experience. I recommend looking at the ROBLOX Wiki pages to gain a better understanding

Ad
Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

One way you could do is edit the cframe of a player's torso, but I do not know if its no longer a good way, or was one from the start.

local player = game:GetService("Players").LocalPlayer --was the -1 because I forgot this?
local character = player.Character -- you could do player:WaitForChild("Character") or something
local other_platform = Workspace:FindFirstChild("OtherPlatform")


if (other_platform) then 
    character.Torso.CFrame = other_platform.CFrame * CFrame.new(0, 5, 0) --maybe not a good idea
end
0
-1? TheLowOne 85 — 7y

Answer this question