Teleportation

From Goodblox Wiki
Revision as of 20:43, 23 June 2020 by Pizzaboxer (talk | contribs) (Created page with "{{CatUp|Tutorials}} __TOC__ == Introduction == Teleportation, a script commonly requested, is a script that moves a player or model, as a whole, to another location, instantly...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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 another 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
for i = 1, 10 do
c[i].Reflectance = i / 10
c[i].Transparency = i / 10
wait(.1)
end
end
end

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

for i = 1, #c do
if c[i].className == "Part" then
for i = 9, 0, -1 do
c[i].Reflectance = i / 1
c[i].Transparency = i / 1
wait(.1)
end
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.