RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"add prints so you know how many more seconds are left in rounds"
-- server script local function startRound() if #players:GetPlayers() < minPlayers then print("Not enough players to start a round.") return end print("Starting round...") local alivePlayers = {} for _, player in pairs(players:GetPlayers()) do if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then table.insert(alivePlayers, player) end end if #alivePlayers == 0 then return end local newBallHolder repeat newBallHolder = alivePlayers[math.random(#alivePlayers)] until newBallHolder ~= ballHolder if ballHolder and playerStates[ballHolder.Name] then playerStates[ballHolder.Name].HasBall = false end ballHolder = newBallHolder playerStates[ballHolder.Name] = {HasBall = true, IsAlive = true} print(ballHolder.Name .. " is the ball holder for this round.") for _, player in pairs(alivePlayers) do local character = player.Character if character and #spawnLocations > 0 then local randomPos local randomIndex repeat randomIndex = math.random(#spawnLocations) local randomSpawn = spawnLocations[randomIndex] randomPos = randomSpawn.Position until (randomPos - ballStartPos).Magnitude > ball.Size.Magnitude * 2 character.HumanoidRootPart.CFrame = CFrame.new(randomPos) table.remove(spawnLocations, randomIndex) end end end while true do task.wait(5) if #players:GetPlayers() >= minPlayers then startRound() if ballHolder and playerStates[ballHolder.Name] then moveBallToHolder() end local roundEndTime = os.time() + 60 while os.time() < roundEndTime and #players:GetPlayers() > 1 do local miniRoundEndTime = os.time() + 10 while os.time() < miniRoundEndTime and #players:GetPlayers() > 1 do print("Mini round ends in ".. (miniRoundEndTime - os.time()) .." seconds") task.wait(1) end if ballHolder and playerStates[ballHolder.Name] then print(ballHolder.Name .. " has been eliminated.") ballHolder.Character.Humanoid.Health = 0 playerStates[ballHolder.Name].IsAlive = false table.remove(players:GetPlayers(), ballHolder) if #players:GetPlayers() > 1 then print("Starting new mini round...") startRound() if ballHolder and playerStates[ballHolder.Name] then moveBallToHolder() end else print(players:GetPlayers()[1].Name .. " wins the round!") roundReset() end end end else print("Not enough players to start a round.") end end