Teleportation: Difference between revisions
>Zitbam |
>Mindraker Rev, why...? PS Has anyone looked at Zitbam's contribs? |
||
Line 74: | Line 74: | ||
end | end | ||
me.Character.Torso.CFrame = CFrame.new(Vector3.new( | me.Character.Torso.CFrame = CFrame.new(Vector3.new(20, 10, 20)) | ||
for i = 1, #c do | for i = 1, #c do |
Revision as of 16:34, 6 September 2008
Introduction
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?
CFrame records where you are. The teleporters change your CFrame, so that you can popup in aother area. So, why can't 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 when you are teleported. Your character is all connected, so 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.