If there’s a Team called “Headquarters” then the player will be get team if there is no team called “Headquarters” the game will create a new Team using Instance.new()
and if the player leave the game and there is no players in the team the team will be get deleted how do I do that?
Why do you need to delete it in the first place?
local Teams = game:GetService('Teams')
if not Teams:FindFirstChild('Headquarters') then --//Checking if the team exists
local newTeam = Instance.new('Team')
newTeam.TeamColor = BrickColor.new('Toothpaste')
newTeam.Name = 'Headquarters'
newTeam.Parent = Teams --//Making the team
end
Teams.ChildAdded:Connect(function(team) --//Called when the team gets added
if team.Name == 'Headquarters' then
team.PlayerRemoved:Connect(function() --//Called when a player leaves
if table.getn(team:GetPlayers()) == 0 then --//Checking how many players are on the team, if it is 0 then we will proceed
team:Destroy() --//Removing the team
end
end)
end
end)
Thank you so much It’s working!
Because it’s kinda clean if you delete the team when player isn’t in that team
Or you could just hide the leaderboard and make your own.