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

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

Asked by 8 years ago

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

Log in to vote
4
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

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)
0
Thanks. ISellCows 2 — 8y
Ad

Answer this question