Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my script removing the team like it should?

Asked by
Vulro 0
4 years ago

The script is supposed to remove the team owners team when they leave and move other team members to the rogues team but it only works when there is someone in the team other than the leader, It's only moving the other players to rogues and not removing the team. What am I doing wrong?

function Leaving(Player)
if Player.Team ~= nil and Player.Team.Leader.Value == Player.Name then
local LeaderTeam = Player.Team  
for i, v in pairs(Player.Team:GetPlayers()) do
  v.Team = game.Teams.Rogues
  LeaderTeam:Remove()
  end
 end
end
game.Players.PlayerRemoving:connect(Leaving)

Answer this question