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

"Unable to cast string to int64" even though the argument is an int?

Asked by 5 years ago
Edited 5 years ago

I tried tonumber() an already number. Didn't work

Server Script

01repeat wait() until game.Workspace
02 
03local TeleportService = game:GetService("TeleportService")
04 
05local Remote = script.Parent.Event
06 
07Remote.OnServerEvent:Connect(function(SentFrom, Setting, ExtraData)
08    if string.lower(Setting) == "teleport" then
09        local finished, err = pcall(function()
10            local Code = TeleportService:ReserveServer(ExtraData)
11            TeleportService:TeleportToPrivateServer(4805466213, Code, {SentFrom})
12        end)
13 
14        if not finished then
15            warn(err)
16        end
17    end
18end)

Local Script

01function GenCode(Len, Al, Num, Special, Space)
02 
03    local Len_Code = Len
04 
05    local Alphabet = Al
06    local Numbers = Num
07    local SpecialCharacters = Special
08    local Space = Space
09 
10    local alphabet = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
11    local numbers = '1234567890'
12    local specialcharacters = '{}!@#$%^&*()_+-=[]\\/.,*+'
13    local space = ' '
14    local output = ''
15 
View all 52 lines...
0
can we see the functions `GenCode`? User#23252 26 — 5y
0
You can't use the placeID / gameID to teleport to a ReservedServer, use the reserved server code maumaumaumaumaumua 628 — 5y
0
all it does is generate a random code with letters and numbers and is returned as a string BradNewTypical 232 — 5y
0
Brad, can we see the function GenCode? User#23252 26 — 5y
View all comments (6 more)
0
Ok now BradNewTypical 232 — 5y
0
NVM, can you just tell me what the function is suppose to do and return? User#23252 26 — 5y
0
It generates a random string that has the length of 6 as the private server code. BradNewTypical 232 — 5y
0
You cannot reserve a server to an invalid PlaceId Ziffixture 6913 — 5y
0
ohh i see the problem User#23252 26 — 5y
0
lemme write an answer User#23252 26 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

The function TeleportService:ReserveServer takes 1 argument. That argument is the place id of the place you want to reserve a server at.. the function returns a code, this code is passed to TeleportService:TeleportToPrivateServer as the second argument.. The argument list of TeleportService:TeleportToPrivateServer is:

1: onces again the place Id where you reserved server

2:server code returned from ReserveServer

3: players to teleport

however, you passed a custom made(ExtraData) id to ReserveServer, which i assume is a string..

learn more here

0
so no fancy code for joining? BradNewTypical 232 — 5y
0
not at all User#23252 26 — 5y
0
How would I make one then? Where you enter in a special code and join the special server. BradNewTypical 232 — 5y
0
If you truly wish to do this, you can take the output form ReserveServer, and scramble it or hash it in your own way. Ensure you create a function that can decode it. Ziffixture 6913 — 5y
0
Ok, thanks BradNewTypical 232 — 5y
Ad

Answer this question