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

Why does this error "unable to cast string to int"?

Can anyone tell me why this doesn't error creating the server, but when teleporting? The purpose for it is I want it to create a vip server(without people having to pay robux) then automatically teleport them to the server.

Code:

local Player = script.Parent.Parent.Parent.Parent
local TeleportService = game:GetService("TeleportService")

script.Parent.MouseButton1Click:connect(function()
	print("Creating Place")
	local Place = TeleportService:ReserveServer(game.PlaceId)
	print("Teleporting Player")
	wait(0.30)
	TeleportService:Teleport(Place,Player)
end)

Error output gives is unable to cast string to int on line 9.

Any help appreciated.

1 answer

✓ Accepted answer

You're actually using the wrong method to teleport to a reserved server!

The method you're looking for is called TeleportToPrivateServer

local Player = script.Parent.Parent.Parent.Parent
local TeleportService = game:GetService("TeleportService")

script.Parent.MouseButton1Click:connect(function()
    print("Creating Place")
    local Place = TeleportService:ReserveServer(game.PlaceId)
    print("Teleporting Player")
    wait(0.30)
    TeleportService:TeleportToPrivateServer(game.PlaceId, Place, {Player})
end)

1 comment

0

Thanks.

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