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

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

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?!

3 comments

0

Either you're testing in studio or you used a client-sided script in a server is why this happens

0

im testing in studio. i'll try in Play Mode.

0

it doesn't work in the server either.

2 answers

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.

I tried in the servers, but it still flopped.

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