it doesn't seem to delete the team... Serverscript in ServerScriptService:
game.ReplicatedStorage.Teams.Teamen.OnServerEvent:Connect(function(player, team)
local realteam = game.Teams:FindFirstChild(team)
if game.Teams:FindFirstChild(team) then
player.TeamColor = realteam.TeamColor
player:LoadCharacter()
else
local clone = game.ReplicatedStorage.TTeams:FindFirstChild(team):Clone()
clone.Parent = game.Teams
wait(0.1)
player.TeamColor = game.Teams:WaitForChild(team).TeamColor
player:LoadCharacter()
clone.Kill.Disabled = false
end
end)
This is a script in the Team that needs to be deleted if there is no anyone on it:
script.Parent.PlayerRemoved:Connect(function()
local team = script.Parent
wait()
if #team:GetPlayers() == 0 then
script.Parent:Destroy()
end
end)

1 comment
It probably has something to do with the fact that the script is inside the team. Either it doesn't run from within game.Teams or it's because you are destroying the script's parent, though I don't remember if scripts do run in game.Teams since I've never actually tried.