Help with private server

image
It shows this error from this script

-- Script
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

Players.PlayerAdded:Connect(function(LocalPlayer)
	local IsPrivateServer = Instance.new("BoolValue", LocalPlayer)
	IsPrivateServer.Value =  false
	IsPrivateServer.Name = "IsPrivateServer"
	
	if LocalPlayer.UserId == game.PrivateServerOwnerId then
		warn("PRIVATE SERVER")
		IsPrivateServer.Value = true
	else
		warn("PUBLIC SERVER")
	end
end)

local function TP(ID, ReserveServerID, Player)
	TeleportService:TeleportToPrivateServer(tonumber(ID), ReserveServerID, Player) -- error here
end

game:GetService("ReplicatedStorage"):WaitForChild("TpPlayerPrivateServer").OnServerEvent:Connect(function(LocalPlayer, ID, UserID)
	warn(LocalPlayer, ID, UserID)
	
	local Player = Players:GetPlayerByUserId(tonumber(UserID))
	
	print(Player)
	
	local ReserveServerID = TeleportService:ReserveServer(tonumber(ID))
	
	TP(ID, ReserveServerID, Player)
end)
-- Local script
local LocalPlayer = game.Players.LocalPlayer
local TeleportService = game:GetService("TeleportService")

local ID = 15691218136

script.Parent.MouseButton1Up:Connect(function()
	if LocalPlayer:WaitForChild("IsPrivateServer").Value == true then
		game:GetService("ReplicatedStorage"):WaitForChild("TpPlayerPrivateServer"):FireServer(ID, LocalPlayer.UserId)
	else
		TeleportService:Teleport(15691218136, LocalPlayer)
	end
end)

I dont know what is wrong.
Basically I am doing a teleport gui to teleport players to other places in my game. I am making a script that detect if a player is in a private server in my game to when the player the player choose a place to teleport it don’t go to a public server of the place.

Public main place = Public Server
Private main place = private server

please help

1 Like

Basically what this error means is that one of the parameters you’ve filled in are an object or instance when it shouldn’t be. For example, if you put a part from the workspace as one of the parameters, you would get the same error (I think)

The 3rd parameter needs to be an array of all players you want to teleport, even if it’s only one player. So to fix this, keep everything on the line the same, but put curly brackets {} around your player variable:

TeleportService:TeleportToPrivateServer(tonumber(ID), ReserveServerID, {Player})
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.