Teleportation

From Legacy Roblox Wiki
Revision as of 11:28, 30 June 2008 by >Mindraker (rm "in closing" section)
Jump to navigationJump to search

What Is Teleportation?

Teleportation, a script commonly requested, is a script that moves a player or model, as a whole, to another location, instantly. For some reason, a lot of people think it's high-level scripting, which it isn't. Just follow this simple tutorial, and you'll be familiar in no time!


How Does It Work?

Teleporting is simple, and easy. All parts (bricks) have a CFrame object. A CFrame keeps track of the coordinates of an object. When you change a CFrame, the object is instantly moved to the proper CFrame, bringing any parts connected to it, with it.--An exception may occur. (furnace speaking) Only bricks with a connection such as a weld or motor (object) to a brick will move with it. Since your legs, arms, and your head are connected to the torso via a weld/motor object, they all move with the torso. Though, Zuka says different. Zuka says that anything JOINTED to it, in any way, whether its welds or whatever, it goes with it. If you want to move a model where the parts aren't all connected via a weld/motor object, then use the :MoveTo(Vector3 location) method.

So... How Do I Do It?

Easy! Just define a new CFrame for the object! Let's say we want to move a player. Well, since the Torso is connected to all of a player's parts, we'll change it's CFrame, as follows:

    game.Workspace.JustinP231.Torso.CFrame = CFrame.new(Vector3.new(0, 0, 0))

Just substitute your name for 'JustinP231' and fill in the coordinates.

Other Uses

There are other uses for CFrames, too! You could send someone to a random location, by using the 'math.random()' function! Ex:

    game.Workspace.JustinP231.Torso.CFrame = CFrame.new(Vector3.new(math.random(-200, 200), 30, math.random(-200, 200))

You could even teleport someone relative to their current location, like 50 studs up, for example!

torso = game.Workspace.Zuka.Torso
torso.CFrame = torso.CFrame + Vector3.new(0,50,0) -- note that I used Vector3.

The possibilities are nearly endless!

BONUS!!!

As an added bonus, I'll even give you a script you can copy and paste, that'll teleport everyone on the map!

    p = game.Players:GetChildren()
    for i = 1, #p do
    p[i].Character.Torso.CFrame = CFrame.new(Vector3.new(0, 0, 0))
    wait(1) -- waits 1 second
    end

Adding Effects

When you have mastered basic teleportation, you can start to experiment, and add special effects. For example:

local me = game.Players.N2KC
local c = me.Character:GetChildren()
for i = 1, #c do
if c[i].className == "Part" then
c[i].Reflectance = .1
c[i].Transparency = .1
wait(.1)
c[i].Reflectance = .2
c[i].Transparency = .2
wait(.1)
c[i].Reflectance = .3
c[i].Transparency = .3
wait(.1)
c[i].Reflectance = .4
c[i].Transparency = .4
wait(.1)
c[i].Reflectance = .5
c[i].Transparency = .5
wait(.1)
c[i].Reflectance = .6
c[i].Transparency = .6
wait(.1)
c[i].Reflectance = .7
c[i].Transparency = .7
wait(.1)
c[i].Reflectance = .8
c[i].Transparency = .8
wait(.1)
c[i].Reflectance = .9
c[i].Transparency = .9
wait(.1)
c[i].Reflectance = 1
c[i].Transparency = 1
wait(.1)
end
end

me.Character.Torso.CFrame = CFrame.new(Vector3.new(20, 10, 20)

for i = 1, #c do
if c[i].className == "Part" then
c[i].Reflectance = .9
c[i].Transparency = .9
wait(.1)
c[i].Reflectance = .8
c[i].Transparency = .8
wait(.1)
c[i].Reflectance = .7
c[i].Transparency = .7
wait(.1)
c[i].Reflectance = .6
c[i].Transparency = .6
wait(.1)
c[i].Reflectance = .5
c[i].Transparency = .5
wait(.1)
c[i].Reflectance = .4
c[i].Transparency = .4
wait(.1)
c[i].Reflectance = .3
c[i].Transparency = .3
wait(.1)
c[i].Reflectance = .2
c[i].Transparency = .2
wait(.1)
c[i].Reflectance = .1
c[i].Transparency = .1
wait(.1)
c[i].Reflectance = 0
c[i].Transparency = 0
wait(.1)
end
end

Just change your the name in the first line to your name, and you will be teleported to the location noted in the middle of the script.