This script teleports all players to an area where they kill each other. I am not sure how I would make it check to see if there is only one player left alive.
local minPlayers = 1
local text = game.Workspace.LobbySign.SurfaceGui.TextLabel
function teleportAllPlayers()
local target = CFrame.new(-1092.5, -337, 2493.501)
for i, player in ipairs(game.Players:GetChildren()) do
player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
gun = game.ReplicatedStorage.Pistol:Clone()
gun.Parent = player.Backpack
player.Playing.Value = 1
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(5)
if #game.Players:getPlayers() >= minPlayers then
if playersCurrentlyPlaying() then
text.Text = ("Match in progress...")
else
text.Text = ("Beginning a new match...")
wait(4)
teleportAllPlayers()
end
else text.Text = ("Waiting for 1 more player to join before starting...") end
end
