WARNING! SCRIPTING CONTENT!
game:GetService("TeleportService"):Teleport(1818)
Looks simple yes? It is! Now, if you don't know what a LocalScript is, then read this page: LocalScript
Ok, now you should know what LocalScripts are! So, in order to teleport someone to another game, it must be in a LocalScript.
There are two functions for TeleportService. Here they are:
game:GetService("TeleportService"):Teleport(int placeId)
--Teleports the LocalPlayer to the given placeId
game:GetService("TeleportService"):TeleportToSpawnByName(int placeId, string spawnName)
--Teleports the LocalPlayer to the given placeId and spawns them at the SpawnLocation named spawnName if found
I made a Gui as soon as I knew how to use the functions, which was before the feature was even out, and using it, you can now place actual game ads in your game that will allow people to teleport right to the advertised game!
Here is the Gui: BCGames' Game Ad GUI
To use this, there are a few things to edit.
First thing is the Table. The table looks like this:
Ads = {
{PlaceId,"PlaceName"},
{PlaceId,"PlaceName"}
}
Now, to add a place to the advertised list, you would edit it like so:
Ads = {
{3138584,"Sandbox BC"},
{46315274,"Sandbox NBC"}
}
You can add as many as you want! Just remember to add a comma at the end of each '{PlaceId,"PlaceName"}' EXCEPT for the last one!
There are two other options.
Position and Randomize.
With Position you can choose where the Gui will be placed.
Randomize makes the Ads appear in a random order rather than in a certain order.
Enjoy!
PS: The model is actually a LocalScript, and will create the Gui when a player enters the game. Simply double click the LocalScript to edit it!
-BCGames
This is very useful. I will try to get this implemented into my games aswell.
ReplyDelete