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

How do I make a script that auto teams a bunch of teams instead of only one?

I am trying to make a script that auto teams you if you are in a certain group Script:

local groupid = 7094704 
local player = game.Players.LocalPlayer

if player:IsInGroup(7094704) then

	player.Team = "Enlisted"
	
local groupid = 8101452 
local player = game.Players.LocalPlayer

if player:IsInGroup(8101452) then

	player.Team = "Army Command"
		
local groupid = 7094704 
local player = game.Players.LocalPlayer

if player:IsInGroup(7441047) then

		player.Team = "Enlisted"

local groupid = 8101452 
local player = game.Players.LocalPlayer

			if player:IsInGroup(7441047) then

			player.Team = "Recruitment & Training"
			else
				plr.team = "Civilian"	
	

end

2 answers

✓ Accepted answer

Switching teams securely must be done on a server script, not a local one. To do this we will use the *PlayerAdded *event under the **Players **service. Here is what the code will look like:

--> Script to be placed under ServerScriptService
local plrs = game:GetService("Players");
local teams= game:GetService("Teams");
plrs.PlayerAdded:Connect(function(plr)
    if plr:IsInGroup(8101452) then
        plr.Team = teams["Army Command"];
    elseif plr:IsInGroup(7094704) then
        --... Replace with this format
    end
end);

3 comments

0

Can I DM you about it?

0

On discord?

0

@BrianH#5428

I would suggest you adding the teams already instead of using instance.new().

and then doing a simple script:

`local groupid = id of the group local player = game.Players.LocalPlayer

if player:IsInGroup(groupid) then

player.Team = "teamname"

end`

2 comments

0

Script didn't work

0

I will post the script I made and see if you can find any bugs with it because I can't seem to be able to fix this one either

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