Hello devs, i need help for my script. I wanna kill everyone on the map when the game end.
local intermission = 25
local roundLength = 450
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
inRound:GetPropertyChangedSignal('Value'):Connect(function()
if not inRound.Value then
for i, plr in pairs(game.Players:GetChildren()) do
pcall(function()
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
end)
end
end
end)
local function round()
while true do
local requiredPlayers = 2
repeat
task.wait(1)
staus.Value = " ".. requiredPlayers.." players needed to play."
until #game.Players:GetChildren() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
task.wait(1)
end
inRound.Value = true
task.wait(3)
for i = roundLength, 0, -1 do
task.wait(1)
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for i, plr in pairs(game.Players:GetChildren()) do
if plr.Team.Name == "Playing" then
table.insert(playing, plr.Name)
print("inserted player")
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
task.wait(3)
break
end
if #playing == 1 then
staus.Value = playing[1].." Has Won The Game!"
for i, plr in pairs(game.Players:GetChildren()) do
if playing[1] == plr.name then
plr.leaderstats.Wins.Value += 1
plr.leaderstats.Money.Value += 25
end
end
wait(3)
break
end
end
end
end
spawn(round)
If someone can help me to fix that .
-Tnks