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
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);
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`