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

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

Asked by 3 years ago
Edited 3 years ago

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

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

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);
0
Can I DM you about it? ConorG234 39 — 3y
0
On discord? ConorG234 39 — 3y
0
@BrianH#5428 HappyHammer55555 99 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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`

0
Script didn't work ConorG234 39 — 3y
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 ConorG234 39 — 3y

Answer this question