You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to solve the problem with the ending round -
What is the issue? Include screenshots / videos if possible!
The issue is when 1 player dead and second is live, and at the ending round writes, that 2 players survived
Here is my script
local Maps = game.ReplicatedStorage.Maps:GetChildren()
local Status = game.ReplicatedStorage.Status
local function arePlayersAlive()
for _, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if Humanoid and Humanoid.Health > 0 then
return true
end
end
end
return false
end
local function getSurvivingPlayers()
local survivingPlayers = {}
for _, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if Humanoid and Humanoid.Health > 0 then
table.insert(survivingPlayers, Player.Name)
end
end
end
return survivingPlayers
end
while true do
wait(.1)
for i = 20, 0, -1 do
Status.Value = "Intermission: " .. i
task.wait(1)
end
local ChosenMap = Maps[math.random(1, #Maps)]
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = game.Workspace
Status.Value = "Map: " .. ClonedMap.Name
task.wait(3)
for _, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
HumanoidRootPart.CFrame = ClonedMap.TeleportPoint.CFrame
end
end
end
local gameOver = false
for i = 10, 0, -1 do
Status.Value = "Game: " .. i
task.wait(1)
if not arePlayersAlive() then
Status.Value = "No one survived!"
task.wait(1)
gameOver = true
break
end
end
if not gameOver then
local survivingPlayers = getSurvivingPlayers()
if #survivingPlayers > 0 then
Status.Value = "Surviving players: " .. table.concat(survivingPlayers, ", ")
else
Status.Value = "No one survived!"
end
end
task.wait(2)
for _, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
HumanoidRootPart.CFrame = Lobby.TeleportPoint.CFrame
end
end
end
ClonedMap:Destroy()
end