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

TeleportToPrivateServer is not working?

Asked by 4 years ago
Edited 4 years ago

Hello everyone, I've made a script that would teleport players to another game that is apart of the starter place but it ain't working. Any help?

Code:

local TeleportService = game:GetService("TeleportService")
 local TS = game:GetService("TeleportService")
 local Players = game:GetService("Players")
 local code = TS:ReserveServer(5488852205) 

 function onPartTouch(otherPart)
    local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
    if player then
        TS:TeleportToPrivateServer(5488852205,code,player)
end
end
script.Parent.Touched:Connect(onPartTouch)

The error that is shown on /console:

07:02:27 -- Unable to cast value to Objects Stack Begin Script 'Workspace.TeleporttoCabin.5.hello.script', Line 11 - function onPartTouch Stack End

Any support would be appreciated, thanks!

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The third parameter for this function has to be a table which would be the player(s) that would be teleported to the private server. You can simply put 'player' into a table by just doing TS:TeleportToPrivateServer(5488852205, code, {player}).

0
Thanks it worked! johncrazy1rb 11 — 4y
0
No problem. xInfinityBear 1777 — 4y
0
Thank you, I was having the same problem and this fixed my problem! 2 years later! IIApexGamerII 76 — 1y
Ad

Answer this question