What do you want to achieve? Change the Status.
Here is the script:
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local LobbyTeam = game.Teams.Lobby
local TowerTeam = game.Teams.Tower
local AttackerTeam = game.Teams.Attacker
local Towers = game.ReplicatedStorage.Towers:GetChildren()
local IntermissionTime = 10
local RoundTime = 180
local MinPlayers = 1
local function tpPlayers()
local players = Players:GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
for i, player in players do
if player == pickedPlayer then
player.Team = AttackerTeam
player.Character.HumanoidRootPart.CFrame = game.Workspace.AttackerPos.CFrame
else
player.Team = TowerTeam
player.Character.HumanoidRootPart.Position = Vector3.new(math.random(-14, 14), 166.5, math.random(120, 148))
end
end
end
local function tpPlayersBack()
local players = Players:GetPlayers()
for i, player in players do
player.Team = LobbyTeam
player.Character.HumanoidRootPart.Position = Vector3.new(0, 196, -27.5)
end
end
local function Countdown(duration)
for i = duration, 1, -1 do
workspace:SetAttribute("Clock", i)
task.wait(1)
end
end
local function Intermission()
workspace:SetAttribute("Status", "Intermission")
Countdown(IntermissionTime)
tpPlayers()
end
local function InGame()
workspace:SetAttribute("Status", "Game")
Countdown(RoundTime)
tpPlayersBack()
end
local function isTeamDead(teamName) **--Focus on this part of the script**
local team = Teams:FindFirstChild(teamName)
if not team then
warn("Team not found.")
return false
end
local playersInTeam = Players:GetPlayers()
for _, player in playersInTeam do
if player.Team == team then
local character = player.Character
if character and character:FindFirstChild("Humanoid") then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid.Health > 0 and team == TowerTeam then
workspace:SetAttribute("Status", "Attacker Wins!")
elseif humanoid.Health > 0 and team == AttackerTeam then
workspace:SetAttribute("Status", "Tower Wins!")
end
end
end
end
end
while true do
if #Players:GetPlayers() >= MinPlayers then
Intermission()
workspace:SetAttribute("Status", "Loading Tower...")
local randomTower = Towers[math.random(#Towers)]
local newTower = randomTower:Clone()
newTower.Parent = workspace
task.wait(1)
InGame()
newTower:Destroy()
else
warn("WAITING FOR PLAYERS...")
workspace:SetAttribute("Status", "Waiting for Players...")
task.wait(1)
end
isTeamDead("Tower")
end
I have been working on this for so long so thanks for any help ![]()