Teleportation: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mindraker
m minor edit
>Outofspace
Does this help?
Line 3: Line 3:


== How Does It Work? == <!-- This is the section that needs help -->
== How Does It Work? == <!-- This is the section that needs help -->
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 are not all connected via a weld/motor object, then use the :MoveTo(Vector3 location) method.


So, how does teleporting work? Imagine you're in a big box. So big, you can fit 25 of your friends/family/cousins in there. But today you're going to be the only one in the box, leaving allot of space for you to walk around in. Now, lets say there are these 2 small bricks in there. Apon touching it, you're instantly moved to the other. Why? Because of CFrame. CFrame records where you're at in the box. The teleporters change your CFrame, so that you can popup in aother area. So, why can it teleport all things? It has to have a weld. All of the parts need to be connected for you to be teleported. If not, you're not going to popup in one piece on the other side. Your [[character]] is all connected, do you teleport in one piece.
<b>Note:</b>If all parts are not connected, use :MoveTo(#,#,#) to move them, otherwise use CFrame.
== How Do I Do It? ==
== How Do I Do It? ==
Just define a new CFrame for the object.  Let's say we want to move a player.  Since the Torso is connected to all of a player's parts, we will change its CFrame, as follows:
Just define a new CFrame for the object.  Let's say we want to move a player.  Since the Torso is connected to all of a player's parts, we will change its CFrame, as follows:

Revision as of 17:59, 30 June 2008

What Is Teleportation?

Teleportation, a script commonly requested, is a script that moves a player or model, as a whole, to another location, instantly. Teleportation is not high-level scripting -- just follow this simple tutorial to familiarize yourself.

How Does It Work?

So, how does teleporting work? Imagine you're in a big box. So big, you can fit 25 of your friends/family/cousins in there. But today you're going to be the only one in the box, leaving allot of space for you to walk around in. Now, lets say there are these 2 small bricks in there. Apon touching it, you're instantly moved to the other. Why? Because of CFrame. CFrame records where you're at in the box. The teleporters change your CFrame, so that you can popup in aother area. So, why can it teleport all things? It has to have a weld. All of the parts need to be connected for you to be teleported. If not, you're not going to popup in one piece on the other side. Your character is all connected, do you teleport in one piece.

Note:If all parts are not connected, use :MoveTo(#,#,#) to move them, otherwise use CFrame.

How Do I Do It?

Just define a new CFrame for the object. Let's say we want to move a player. Since the Torso is connected to all of a player's parts, we will change its CFrame, as follows:

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

Just substitute your name for 'username' 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, e.g.,:

    game.Workspace.username.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.username.Torso
torso.CFrame = torso.CFrame + Vector3.new(0,50,0) -- note that I used Vector3.

Here is a script you can copy and paste, that will 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.