Need help with Server List

Hi!

I am making a server list system and I need help with the creation of private servers. The private servers should be displaying on the server list and you should be able to join them but it still says the place is restricted even though the access code is the correct one.

In the client script this gets repeatedly displayed:

image

Server Script:

local ServersFolder = game:GetService("ReplicatedStorage"):WaitForChild("Servers")
local MessagingService = game:GetService("MessagingService")
local TPS = game:GetService("TeleportService")

MessagingService:SubscribeAsync("ServerList", function(data)
	
	data = data.Data
	
	if data.serverId ~= game.JobId then
		
		local serverValue = script:WaitForChild("ServerName"):Clone()
		
		serverValue.Value = data.serverId .. " " .. data.players
		
		serverValue.Parent = ServersFolder
		
		task.wait(5)
		
		serverValue:Destroy()
		
	end
	
end)

game:GetService("ReplicatedStorage"):WaitForChild("CreateServer").OnServerEvent:Connect(function(player)
	
	local AccessCode = TPS:ReserveServer(13628003081)

	TPS:TeleportToPrivateServer(13628003081, AccessCode, {player})

end)

while true do
	
	if game.PrivateServerId == "" then
		
		local data = {

			serverId = game.JobId,
			players = #game:GetService("Players"):GetPlayers()

		}

		MessagingService:PublishAsync("ServerList", data)
		
	else
		
		local data = {

			serverId = game.PrivateServerId,
			players = #game:GetService("Players"):GetPlayers()

		}

		MessagingService:PublishAsync("ServerList", data)
		
	end
	
	task.wait(5)
	
end

Client Script:

local function UpdateGui()
	
	local ServerFrames = {}
	
	for i, v in pairs(game:GetService("ReplicatedStorage"):WaitForChild("Servers"):GetChildren()) do
		
		local name = v.Name
		
		local ServerStats = string.split(v.Value, " ")
		
		local ID = ServerStats[1]
		local Players = ServerStats[2]
		
		print(ID)
		
		local ServerFrame = script:WaitForChild("Template"):Clone()
		
		ServerFrame:WaitForChild("ServerName").Text = name .. "/".. game:GetService("Players").MaxPlayers
		ServerFrame:WaitForChild("Players").Text = Players.."/"..game:GetService("Players").MaxPlayers
		
		table.insert(ServerFrames, ServerFrame)
		
		ServerFrame:WaitForChild("JoinButton").MouseButton1Click:Connect(function()
			
			local success, errorMessage = pcall(function()
				
				game:GetService("TeleportService"):TeleportToPlaceInstance(game.PlaceId, ID, game:GetService("Players").LocalPlayer)
				
			end)
			
			if not success then
				
				game:GetService("TeleportService"):TeleportToPrivateServer(game.PlaceId, ID, {game:GetService("Players").LocalPlayer})
			
			end
			
		end)
		
		script.Parent:WaitForChild("ScrollingFrame"):ClearAllChildren()
		
		script.UIListLayout:Clone().Parent = script.Parent:WaitForChild("ScrollingFrame")
		
		for i, v in pairs(ServerFrames) do
			
			v.Parent = script.Parent:WaitForChild("ScrollingFrame")
			
		end
		
	end
	
end

UpdateGui()

game:GetService("ReplicatedStorage"):WaitForChild("Servers").ChildAdded:Connect(UpdateGui)
game:GetService("ReplicatedStorage"):WaitForChild("Servers").ChildRemoved:Connect(UpdateGui)

script.Parent:WaitForChild("Create").MouseButton1Click:Connect(function()
	
	game:GetService("ReplicatedStorage").CreateServer:FireServer()
	
end)

Is that being tested in Studio? If so, I think you should try testing it actually in game (so not in Studio).

1 Like

Thanks for replying! .It’s being tested in an actual game

2 Likes

Could you possibly highlight the line that’s being errored? Thank you.

1 Like

Of course. Here is the error line:

Edit: Although this error is occurring I still don’t understand why the private server is restricted even with the right code

About the Parent property being locked, apparently it has to have been destroyed for that error to occur.

With the private server restriction, I’d have to look into that, i’ll get back to you with some info I can gather.

Also, is the place you’re attempting to teleport to public and is Third-Party teleports enabled in your game’s settings?

Hi, thanks for the help.

The place I’m attempting to join is a private server using TeleportService:ReserveServer() and yes Third-Party teleports are enabled

I meant is the game you’re teleporting to set as private (not if it’s a private server). Cause I’ve had a problem with this before when I was trying to make a matchmaking system.

The place I’m trying to teleport to is a new instance of the same game as I’m making a server list

Wait, maybe try wrapping TeleportToPrivateServer() in a pcall and tell me what happens.

EDIT: I’m trying to find a solution right now

Hey. Nothing comes out of the pcall but in the client script I get this error:

It might be a firewall blocking something. Or just an internal problem, maybe try testing on another device (if possible).

It’s me and my friend testing, one of us creates the server which works, it teleports them to the new server and the UI shows on my screen (in the original server) and when I press join it says it’s restricted.

Okay, that’s really weird. I think if you can, try to get a Roblox staff to reply. Honestly I’m not sure if you can submit a bug report but if you can then you should.

Thanks for the help. It now says that the access code is invalid even though I printed the code in both instances and they’re both the same values. If you find anything else that might help please let me know.

1 Like

Weird question but is the teleport place published?

Yeah it is, thanks for replying!