Client Side Code :
local GameId = 6305504610 --Line 148
print("GameId "..GameId) --Line 149
print("PlayerName "..plr.Name) --Line 150
local teleporting = game.ReplicatedStorage.Check:InvokeServer(plr , GameId) --Line 151
Server Side Code :
local rs = game:GetService("ReplicatedStorage")
local Teleport = game:GetService("TeleportService")
local CNT = 0
local function checkandteleport (plr , GameId)
GameId = 6305504610
print("GameId "..tostring(GameId))
print("Player Name "..plr.Name)
local plrs = {plr}
print(tostring(plrs))
if game.PrivateServerId ~= "" and game.PrivateServerOwnerId ~= 0 then
print("Teleporting to a Private server")
local code = Teleport:ReserveServer(GameId)
print(tostring(GameId))
print(tostring(plr))
print(code)
print("Player getting teleported is "..tostring(plrs))
local Success,Error = pcall (Teleport:TeleportToPrivateServer(GameId , code , plrs))
repeat
print("Error" .. Error)
CNT = CNT + 1
wait(5)
local Success,Error = pcall(Teleport:TeleportToPrivateServer(GameId , code , plrs))
until Success or CNT == 3
if CNT == 3 then
plr:Kick("Failed To Teleport")
end
else
print("Teleporting to a Standard Server")
print(tostring(GameId))
print(plr.Name)
print("Player getting teleported is "..tostring(plrs))
local Success,Error = pcall(Teleport:Teleport(GameId , plrs))
repeat
print("Error" .. Error)
CNT = CNT + 1
wait(5)
local Success,Error = pcall(Teleport:Teleport(GameId , plrs))
until Success or CNT == 3
if CNT == 3 then
plr:Kick("Failed To Teleport")
end
end
end
local check = rs:WaitForChild("Check")
check.OnServerInvoke = checkandteleport
Client Side Output:
Game Id 6305504610
PlayerName nkminion
Unable to cast value to Object
Stack Begin
Script 'Players.nkminion.PlayerGui.Menu.MenuMain' , Line 151
Stack End
Server Side Output:
Game Id 6305504610
Player Name nkminion
table : 0x9b3f29256257dcba
Teleporting to a Standard Server
6305504610
nkminion
Player getting teleported is table : 0x9b3f29256257dcba
Unable to cast value to Object
Stack Begin
Script 'ServerScriptService.Script' , Line 33 - function checkandteleport
Stack End
Edit : To provide more context , im making a script that checks if you are in a public server or in a private server. If you are in a public server , it teleports you to another public server. If you are in a private server , it teleports you to a standard server. The problem is that the standard server script does not work Please Help!
