I've been working on this script for a day and I'm still stuck on destroying the team when nobody is on it.
local teams = game.Teams
local random = 0
local teamColor = teams:GetDescendants()
local playerammount = 0
local blueTeam = game.Teams:GetChildren()
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player) ---- Creates the teams based off player names and color based on random number
local newTeam = Instance.new("Team",game.Teams)
newTeam.Parent = teams
newTeam.Name = (player.Name .. "'s Factory")
player.Neutral = false
playerammount = playerammount + 1
if playerammount == 1 and newTeam.Name == (player.Name .. "'s Factory") then
newTeam.TeamColor = BrickColor.new("Really blue")
player.TeamColor = newTeam.TeamColor
elseif playerammount == 2 and newTeam.Name == (player.Name .. "'s Factory") then
newTeam.TeamColor = BrickColor.new("Lime green")
player.TeamColor = newTeam.TeamColor
elseif playerammount == 3 and newTeam.Name == (player.Name .. "'s Factory") then
newTeam.TeamColor = BrickColor.new("Deep blue")
player.TeamColor = newTeam.TeamColor
elseif playerammount == 4 and newTeam.Name == (player.Name .. "'s Factory") then
newTeam.TeamColor = BrickColor.new("Crimson")
player.TeamColor = newTeam.TeamColor
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Players = game.Players:GetChildren()
local blueteam = game:GetService("Teams"):getChildren(teamColor.TeamColor == BrickColor.new("Really blue"))
if player.TeamColor == BrickColor.new("Really blue") then
blueTeam:Destroy()
end
end)
Right now its just returning ServerScriptService.Script:33: attempt to call method 'Destroy' (a nil value). Which from my understand is because its trying to destroy the wrong thing. So basically what I want to know is is there a way i can call the Really blue team and then use :Destroy() on it.

3 comments
Nothing in your PlayerRemoving function makes sense. Review it, literally nothing is correct.
The blueTeam:Destroy() is not indented
Yes lua is python indents matter!! or else ur script died