-
What do you want to achieve? my round system to work
-
What is the issue? idk its just broken lol here’s the video 2022-12-08 09-10-15
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
LobbyTeam = Teams:WaitForChild("Lobby")
RoundTeam = Teams:WaitForChild("Round")
RoundInProgress = false
AreaSpawns = workspace:WaitForChild("GreenAreaSpawns")
function LobbyToRound()
warn("Init - LobbyToRound")
for _, PlayerInLobby in ipairs(LobbyTeam:GetPlayers()) do
local Character = PlayerInLobby.Character or PlayerInLobby.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local RandomSpawnPos = AreaSpawns:GetChildren()[math.random(1, #AreaSpawns:GetChildren())].Position
local SkillScript = Character:WaitForChild("SkillReplicator")
Humanoid.MaxHealth = 100
Humanoid.Health = 100
SkillScript.Enabled = true
HumanoidRootPart.CFrame = CFrame.new(RandomSpawnPos)
PlayerInLobby.Team = RoundTeam
end
task.spawn(function()
for x = 300, 0, -1 do -- Round duration
wait(1)
print("Waiting until round ends...")
local PlayersInRound = RoundTeam:GetPlayers()
task.spawn(function()
for _, player in ipairs(PlayersInRound) do
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
player.Team = LobbyTeam
end)
end
end)
if #PlayersInRound ~= 0 then
if #PlayersInRound == 1 then
local Winner = RoundTeam:GetPlayers()[1]
task.spawn(function()
for _, player in ipairs(Players:GetPlayers()) do
player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Champion: "..Winner.Name
end
end)
RoundInProgress = false
RoundToLobby() -- END ROUND
else
for _, player in ipairs(Players:GetPlayers()) do
player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Round in progress: "..x
end
if x <= 0 then
for _, player in ipairs(Players:GetPlayers()) do
player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Game over! No winners :c"
end
RoundInProgress = false
RoundToLobby()
end
end
end
end
end)
end
function RoundToLobby()
warn("Init - RoundToLobby")
task.wait(5)
for _, PlayerInRound in ipairs(RoundTeam:GetPlayers()) do
local Character = PlayerInRound.Character or PlayerInRound.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local CafeSpawn = workspace:WaitForChild("Map").TeleportPart
local SkillScript = Character:WaitForChild("SkillReplicator")
SkillScript.Enabled = false
HumanoidRootPart.CFrame = CFrame.new(CafeSpawn.Position)
Humanoid.MaxHealth = math.huge
Humanoid.Health = Humanoid.MaxHealth
PlayerInRound.Team = LobbyTeam
end
RoundStartCountdown()
end
function RoundStartCountdown()
warn("Init - RoundStartCountdown")
for x = 60, 0, -1 do -- Wait duration in seconds until the round starts
wait(1)
AmountOfPlayersInLobby = #LobbyTeam:GetPlayers()
Requirement = 1
if RoundInProgress == false then
for _, player in ipairs(Players:GetPlayers()) do
player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Time until round start: "..x
end
end
end
if AmountOfPlayersInLobby >= Requirement then
RoundInProgress = true
LobbyToRound() -- START ROUND
end
end
RoundStartCountdown()