Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I create a place and then teleport to it? [SOLVED]

Asked by
sgsharp 265 Moderation Voter
10 years ago

Okay, so I have a GUI that contains a button. And when it is pushed, it is supposed to create a place (and it does...) and then teleport the player who clicked the button to the created place.

**I have a script inside the button, and the code looks like this: **

game:GetService('TeleportService').CustomizedTeleportUI = true

local Players = game.Players:GetPlayers()

for _,v in pairs(Players) do

function CreateServer(v)

        NewPlaceId = game:GetService("AssetService"):CreatePlaceAsync("Building With Friends: Solo Building", 161948626, "A Building With Friends Universe...")
        game:GetService('TeleportService'):Teleport(NewPlaceId, v)

end end

script.Parent.MouseButton1Click:connect(CreateServer)

In the Developer Console (In-game) the output says "Invalid Player To Teleport." Could someone please tell me what I have done wrong?** (Note: this is my first time using the Create Place API, so It's a bit confusing to me. Yes, I have tried the wiki and that just confuses me even more. Help would be greatly appreciated!)**

EDIT:

I have caught my error in the script.

game:GetService('TeleportService').CustomizedTeleportUI = true

local Players = game.Players:GetPlayers()

for _,v in pairs(Players) do

function CreateServer()

        NewPlaceId = game:GetService("AssetService"):CreatePlaceAsync("Building With Friends: Solo Building", 161948626, "A Building With Friends Universe...")
        game:GetService('TeleportService'):Teleport(NewPlaceId, v)

end end

script.Parent.MouseButton1Click:connect(CreateServer)

Answer this question