Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TeleportToPrivateServer is not working?

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

✓ Accepted answer

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}).

3 comments

0

Thanks it worked!

0

No problem.

0

Thank you, I was having the same problem and this fixed my problem! 2 years later!

This discussion is preserved as it was. New answers, comments, and votes are closed.