local roundtext = game.ReplicatedStorage.Values.StatusText
local roundnumber = game.ReplicatedStorage.Values.StatusNumber
local multimaps = game.ServerStorage.MultiMaps:GetChildren()
local singlemaps = game.ServerStorage.SingleMaps:GetChildren()
playing = {}
function checkPlayers(playing)
for i, v in pairs(playing) do
if game.Workspace:FindFirstChild(v) == nil then
table.remove(playing, i)
print(playing)
else
game.Workspace:WaitForChild(v).Humanoid.Died:Connect(function()
table.remove(playing, i)
print(playing)
end)
end
end
end
while wait() do
if #game.Players:GetPlayers() >= 2 then
local countdown = 30
for i = countdown, 0, -1 do
wait(1)
roundtext.Value = "Intermission"
roundnumber.Value = i
end
local chosen = multimaps[math.random(1, #multimaps)]:Clone()
Spawns = chosen:FindFirstChild('Spawns'):GetChildren()
chosen.Parent = workspace
local countdown = 3
for i = countdown, 0, -1 do
wait(1)
roundtext.Value = chosen.Name.." has been chosen!"
roundnumber.Value = i
end
for _, Player in ipairs(game.Players:GetPlayers())do
if Player.Character and Player.Character:WaitForChild('Humanoid') then
RandomSpawn = Spawns[math.random(1, #Spawns)]
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
end
end
playing = {}
for i, v in pairs(game.Players:GetPlayers()) do
table.insert(playing, v.Name)
print(playing)
end
countdown = 5
for i = countdown, 1, -1 do
wait(1)
roundtext.Value = "Be the last one standing!"
roundnumber.Value = i
checkPlayers(playing)
end
local countdown = 90
for i = countdown, 0, -1 do
wait(1)
roundtext.Value = chosen.Name
roundnumber.Value = i
checkPlayers(playing)
if #playing == 1 then
chosen:Destroy()
for i, v in pairs(playing) do
roundtext.Value = "Winners: "..table.concat(playing, ', ')
game.Players:WaitForChild(v).leaderstats.Minicoins.Value += 1
local gamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players:WaitForChild(v).UserId, 13839244)
if gamepass then
game.Players:WaitForChild(v).leaderstats.Minicoins.Value += 1
end
end
wait(3)
end
if #playing == 0 then
chosen:Destroy()
for i, v in pairs(playing) do
roundtext.Value = "Winners: Nobody!"
end
wait(1)
break
end
end
chosen:Destroy()
for i, v in pairs(playing) do
roundtext.Value = "Winners: "..table.concat(playing, ', ')
game.Players:WaitForChild(v).leaderstats.Minicoins.Value += 1
local gamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players:WaitForChild(v).UserId, 13839244)
if gamepass then
game.Players:WaitForChild(v).leaderstats.Minicoins.Value += 1
end
end
wait(3)
else ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local countdown = 30
for i = countdown, 0, -1 do
wait(1)
roundtext.Value = "Intermission"
roundnumber.Value = i
checkPlayers(playing)
if #game.Players:GetPlayers() > 1 then
break
end
end
if #game.Players:GetPlayers() == 1 then
playing = {}
local chosen = singlemaps[math.random(1, #singlemaps)]:Clone()
Spawns = chosen:FindFirstChild('Spawns'):GetChildren()
chosen.Parent = workspace
local countdown = 3
for i = countdown, 0, -1 do
roundtext.Value = chosen.Name.." has been chosen!"
roundnumber.Value = i
wait(1)
checkPlayers(playing)
end
for _, Player in ipairs(game.Players:GetPlayers())do
if Player.Character and Player.Character:WaitForChild('Humanoid') then
RandomSpawn = Spawns[math.random(1, #Spawns)]
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
end
end
for i, v in pairs(game.Players:GetPlayers()) do
table.insert(playing, v.Name)
end
countdown = 5
for i = countdown, 0, -1 do
checkPlayers(playing)
roundtext.Value = "Survive for 60 seconds!"
roundnumber.Value = i
wait(1)
end
local countdown = 60
for i = countdown, 0, -1 do
wait(1)
roundtext.Value = chosen.Name
roundnumber.Value = i
checkPlayers(playing)
if #playing == 0 then
chosen:Destroy()
roundtext.Value = "Winners: Nobody!"
wait(1)
break
end
end
chosen:Destroy()
for i, v in pairs(playing) do
roundtext.Value = "Winners: "..table.concat(playing, ', ')
game.Players:WaitForChild(v).leaderstats.Minicoins.Value += 1
local gamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players:WaitForChild(v).UserId, 13839244)
if gamepass then
game.Players:WaitForChild(v).leaderstats.Minicoins.Value += 1
end
end
wait(3)
end
end
end
Issues im having:
when one or two players die, it will sometimes end the match even when there are more than one players present
only the first player to join the server will be able to win; if someone else wins, it will just end the round without assigning a winner
i would really appreciate any help i get because ive been at this issue since november 2020