How do i make it so a script executes only when a player is in a specific team?
Replace "Red" with whatever team you're looking for on the "game:GetService("Teams").Red" line
if(player.Team == game:GetService("Teams").Red) then ---code end
You have to first set the players in a specific team so to do this, you can create a StringValue in the players when they join the game. This will act as a tag to determine which team they're on in the game. You can then loop through the players with a for loop and check if they have the tag for the specific team. If they do, then run the code for said team.
game.Players.PlayerAdded:Connect(function(players) if players.Name == 'Boi' then local redTeam = Instance.new('StringValue') redTeam.Name = 'RedTeam' redTeam.Parent = players end if players.Name == 'YoBoi1337' then local blueTeam = Instance.new('StringValue') blueTeam.Name = 'BlueTeam' blueTeam.Parent = players end for i,v in pairs(players:GetChildren()) do if v.Name == 'RedTeam' then print('Player is on red team') -- execute the script you want on the red team elseif v.Name == 'BlueTeam' then print('Player is on blue team') -- execute the script you want on the blue team end end end)