Hey, I’m trying to make teams disappear when a player isn’t on the team. I’m not 100% sure what I am supposed to do, it would be appreciated if you could help, thanks!
1 Like
You could use the PlayerRemoved event for teams. So once a player is removed, check how many players are still remaining on the team and if its <= 0 then just destroy the team.
Yeah, you can use PlayerRemoved
event and a for loop
to achieve this.
Something like:
local Teams = game:GetService('Teams')
local function removing() -- Create a function, because we can refer back to it using the for loop
for i, v in pairs(Teams:GetTeams()) do -- Get the teams within the service Teams
v.PlayerRemoved:Connect(function() -- When a player is removed from the team
if #v:GetPlayers() == 0 then -- Check all players have been removed
v:Destroy() -- Destroy team
end
end)
end
end
for i, v in pairs(Teams:GetTeams()) do -- Call function again in for loop
removing(v)
end
Just change the team archivable value to false.