TeleportService Guide: Difference between revisions
>SoulStealer9875 New page: == Introduction == TeleportService was created to teleport the local player from one place to another. === Why Should I use it? === You can use it as a way of advertising someone else's ... |
>Crazypotato4 I added some links to the page |
||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
TeleportService was created to teleport the local player from one place to another. | [[TeleportService]] was created to teleport the local player from one place to another. | ||
=== Why Should I use it? === | === Why Should I use it? === | ||
Line 10: | Line 10: | ||
== How to use it == | == How to use it == | ||
The service runs off the local player, meaning you can't run it off a normal script inside a regular area such as workspace. | The service runs off the [[LocalPlayer|local player]], meaning you can't run it off a normal script inside a regular area such as workspace. | ||
So you will need to insert a LocalScript into a player's PlayerGui, Character, etc. | So you will need to insert a [[LocalScript]] into a player's [[PlayerGui]], [[Character]], etc. | ||
== Creating the script == | == Creating the script == | ||
First of all we need to get the service by using the :GetService() method of 'game'. | First of all we need to get the service by using the [[GetService|:GetService()]] method of [[DataModel|'game']]. | ||
Line 32: | Line 32: | ||
Now we need to use the :Teleport() method of TeleportService. | Now we need to use the [[Teleport_%28Method%29|:Teleport()]] method of TeleportService. | ||
Line 56: | Line 56: | ||
== Extra == | == Extra == | ||
You can also put the LocalScript in Lighting, make a GUI containing a button, when you click the button, the LocalScript can get cloned from Lighting in the player's PlayerGui or Character etc. | You can also put the LocalScript in [[Lighting]], make a [[Beginner%27s_GUI_Tutorial|GUI]] containing a button, when you click the button, the LocalScript can get cloned from Lighting in the player's PlayerGui or Character etc. |
Revision as of 15:04, 22 July 2011
Introduction
TeleportService was created to teleport the local player from one place to another.
Why Should I use it?
You can use it as a way of advertising someone else's place, or your own place as a GUI. So you can click the button and it will teleport you to the place.
How will this benefit me?
It really does depend on how you use it.
How to use it
The service runs off the local player, meaning you can't run it off a normal script inside a regular area such as workspace.
So you will need to insert a LocalScript into a player's PlayerGui, Character, etc.
Creating the script
First of all we need to get the service by using the :GetService() method of 'game'.
game:GetService()
Next we need to insert the name of the service, which is TeleportService. Since the name is a string, we need to put speechmarks around it.
game:GetService("TeleportService")
Now we need to use the :Teleport() method of TeleportService.
game:GetService("TeleportService"):Teleport()
Inside the brakets we need to put the ID of the place we wish to teleport to, my example will be 8473728, just a few random numbers.
game:GetService("TeleportService"):Teleport(8473728)
Teleporting to a certain spawn
With this service you can teleport to a certain spawn, all you need to do is put the spawn's name as the second argument.
game:GetService("TeleportService"):Teleport(8473728, "SpawnLocation")
Extra
You can also put the LocalScript in Lighting, make a GUI containing a button, when you click the button, the LocalScript can get cloned from Lighting in the player's PlayerGui or Character etc.