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
Either you're testing in studio or you used a client-sided script in a server is why this happens
im testing in studio. i'll try in Play Mode.
it doesn't work in the server either.