Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make an auto team script that teams everyone that is in the group to a team?

I am trying to make an auto team script that teams a player on a team if they are the group and if they are not they get teamed to the other team.

My attempt at the script:

game.Players.PlayerAdded:connect(function(player) 
	if player:GroupId = 7094704
		player.Team = "Irish Defence Forces" 
	else 
		player.TeamColor = "Enemies" 
	end)

2 answers

Maybe try

game.Players.PlayerAdded:connect(function(player) 
    if player:GroupId = 7094704
        player.Team = game.Teams["Irish Defence Forces"]
    else 
        player.Team = game.Teams.Enemies
    end)
end

Hope this works! Sorry if it doesn't :(.

Roblox has a function to determine this. Define your player as a variable.

game.Players.PlayerAdded:Connect(function(plr)
    local ID = 7094704
    if plr:IsInGroup(ID) then
        plr.Team = game:WaitForChild("Teams"):WaitForChild("Irish Defense Force")
    else
        plr.team = game:WaitForChild("Teams"):WaitForChild("Enemies")
    end
end

This should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.