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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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 :(.

Ad
Log in to vote
0
Answered by 4 years ago

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.

Answer this question