Hello, today I was wondering how I would find the number of players in a Map. Currently the code just teleports the players to the map in rounds but I have no way to find the number of players in the map. This is partially what the script looks like:
while true do wait(0) if game.Players.NumPlayers >= 2 then maps = game.Lighting:GetChildren() map = maps[math.random(1,#maps)] mapclone = map:Clone() mapclone.Parent = game.Workspace mapclone.Name = "Map" wait(1.5) local spawnsmodel = mapclone:WaitForChild("Spawns") local spawns = spawnsmodel:GetChildren() for i, player in ipairs(game.Players:GetChildren()) do if player and player.Character and #spawns > 0 then local torso = player.Character:WaitForChild("Torso") local humanoid = player.Character:WaitForChild("Humanoid") local spawnindex = math.random(1, #spawns) local spawn = spawns[spawnindex] if spawn and torso and humanoid then table.remove(spawns, spawnindex) torso.CFrame = CFrame.new(spawn.Position) end end end
Essentially, I would want to know which players are in the map or "Playing" and how many are not in the map and are "Spectating"
If you could help with this it would be much appreciated!