Hello, so ive been playing a round in my game and it appears that the round system is broken. ive had teams in the system before but as soon as i took them out the round no longer ends when only 1 person is standing! I dont know how to fix this bug but here is the script:
local intermission = 10
local roundLength = 170
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
inRound.Changed:Connect(function()
if inRound.Value == true then
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:FindFirstChild("HumanoidRootPart")
if humanRoot then
humanRoot.CFrame = game.Workspace.DropGame.RoundSpawn.CFrame
end
end
else
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:FindFirstChild("HumanoidRootPart")
if humanRoot then
humanRoot.CFrame = game.Workspace.Lobby.LobbySpawn.CFrame
end
end
end
end)
local function round()
while true do
local requiredPlayers = 2
repeat
wait(1)
staus.Value = "At least ".. requiredPlayers.." players are needed to start a round"
until #game.Players:GetPlayers() >= requiredPlayers
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
for i = roundLength, 0, -1 do
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for _, plr in pairs(game.Players:GetPlayers()) do
if plr.Team == nil then
table.insert(playing, plr)
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
wait(3)
break
end
if #playing == 1 then
local winner = playing[1]
staus.Value = winner.Name.." Has Won The Game!"
local randomCoins = math.random(20, 100)
winner.leaderstats.Wins.Value += 1
winner.leaderstats.Coins.Value += randomCoins
if winner.MembershipType == Enum.MembershipType.Premium then
randomCoins.Value += math.random()*2
else
randomCoins.Value += math.random()
end
wait(3)
break
end
wait(1)
end
wait(3)
end
end
spawn(round)
It would be nice if somebody helps me fix my issue or look trough the code and fix it for me (after 1 match the round dont restart at all but i think its because ive tried to add premium benifits) also i need help setting the premium benifits because when i tryed to make them i think because of them they broke the system!