TeleportService Guide: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>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 ...
 
>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 ...
(No difference)

Revision as of 12:49, 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.