I took this script directly from the wiki. It's not working, not sending me to the map. I switched minplayers to 1 to test it. I have the lobby spawnpoint, too.

local oldMessage = ""
local minplayers = 2

function teleportAllPlayers()
	local target CFrame.new(workspace.TeleportBlock.Position)
	for i, player in ipairs(game.Players:GetChildren()) do
		player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
		player.Playing.Value = 1
	end
end

function message(message)
	if oldMessage ~= message then
		oldMessage = message
		print(message)
	end
end
 
function playersCurrentlyPlaying()
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.Playing.Value == 1 then return true end
	end
	return false
end
 
game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			player.Playing.Value = 0
		end)
	end)
 
	local playing = Instance.new("IntValue", player)
	playing.Value = 0
	playing.Name = "Playing"
end)
 
 
while(true) do
	wait(10)
	if #game.Players:getPlayers() >= minPlayers then
		if playersCurrentlyPlaying() then
			message("Waiting for the current game to end...")
		else
			message("There are enough players for a new game!  Teleporting...")
			wait(4)
			teleportAllPlayers()
		end
	else message("Waiting for more players...") end
end

I have FilteringEnabled on. I have the TeleportBlock on the map I want the players to spawn. Output gives me this error: ServerScriptService.Script:41: attempt to compare nil with number, when I had stated what minplayers was on the second line. This is a server script, do I need to change it to local? And where would I put it if so?

edit: Thanks for the comment, it answered it for me. I don't know how to mark this as answered if a comment answered it for me.

2 comments

0

It's not working because the script only works with FilterEnabled off.

0

You have to create a RemoteEvent for each function and :FireAllClients()