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

Help! I need to teleport players to a reserved server in my game, but it won't let me! Why?

Asked by 5 years ago
Edited 5 years ago

I have a teleport script, it should work, but it keeps saying this when I test it out:

17:19:22.735 - TeleportService:ReserveServer can only be called by the server.

Here is the code I used:

****NOTE:**** This is a Server-Side script!

local TeleportService = game:GetService("TeleportService")
local id = 1248523004
local ChatService = game:GetService("Chat")
local i = script.Value.Value

script.Parent.Touched:connect(function(h)
    if i == true then
        return
    end
    local player = game.Players:GetPlayerFromCharacter(h.Parent)
    if not player then
        return
    end
    local plrname = player.Name
    local code = TeleportService:ReserveServer(1248523004) -- the error is directed towards here.
    TeleportService:TeleportToPrivateServer(1248523004, code, player)
    i = true
    wait(3)
    i = false
    if player then
         print("Teleport Failed (TeleportScript)")
         ChatService:Chat(script.Parent, "Teleport of "..plrname.." failed. Please try in another server or if this appears again,")
        ChatService:Chat(script.Parent, "message GamingZacharyC or any scripter/programer with Masterful Studios.")
    else
        print("teleporting "..plrname.." to the next level...")
        ChatService:Chat(script.Parent, plrname.." was teleported to the next level.")
    end
end)

Why is it saying this? HOW CAN I FIX IT?!

0
Either you're testing in studio or you used a client-sided script in a server is why this happens spr_ead 47 — 5y
0
im testing in studio. i'll try in Play Mode. GamingZacharyC 152 — 5y
0
it doesn't work in the server either. GamingZacharyC 152 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

This is because it is not a game server. It is a private server it does not show up on the server list so the game cannot find it.

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I tried in the servers, but it still flopped.

Answer this question