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

Teleport Failed to an unexpected error?

Asked by
Mawfix 15
4 years ago
Edited 4 years ago

I'm making a game and im sending people to a separate place within my game. It's a reserved Server so only the people I send will be able to join. Whenever I test it out in Game(Not studio mode) it always pulls up with "Teleport Failed to an unexpected error.(Error Code:769)" Please Help.

local tpService = game:GetService("TeleportService")
local place = (Im not Showing This)

script.Parent.Touched:Connect(function(hit)
    local code = tpService:ReserveServer(game.PlaceId)
    local player = game.Players:GetChildren()
    if player then
        tpService:TeleportToPrivateServer(place,code,player,"StartSpawn",nil,nil)
    end
end)
0
What just happened to the views XD Mawfix 15 — 4y
0
Are you trying to create a private server in a new game or the current game? Azarth 3141 — 4y

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Seems to work for me, my guess is your 'place' id variable wasn't the same as game.PlaceId

local PlayersService = game:GetService('Players')
local TeleportService = game:GetService("TeleportService")

local PlaceId = game.PlaceId
local ReservedServerCode = TeleportService:ReserveServer(PlaceId)

script.Parent.Touched:Connect(function(hit)
    if hit and hit.Parent then 
        local Player = PlayersService:GetPlayerFromCharacter(hit.Parent)
        if Player and Player.Character then 
            local Humanoid = Player.Character:FindFirstChild("Humanoid")
            if Humanoid and Humanoid.Health > 0 then
                -- Use the GetPlayers() method on Players
                local Players = PlayersService:GetPlayers()
                -- Should be > 0 since someone stepped on it
                if #Players > 0 then 
                    TeleportService:TeleportToPrivateServer(PlaceId, ReservedServerCode, Players, "StartSpawn")
                end
            end
        end
    end
end)

0
Thanks I was putting making the server code every time the part was hit. Oops. Mawfix 15 — 4y
Ad

Answer this question