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

Why does automatic teaming script/Speed Script not work?

local Teams = game:GetService('Teams')
local HRs = Teams:WaitForChild('HighRanks')
local Security = Teams:WaitForChild('Security')

game.Players.PlayerAdded:Connect(function(player)
  if player:IsInGroup(2533886) then
		if player:GetRankInGroup(2533886) >= 12 then
			player.Team = HRs
    elseif player:GetRankInGroup(2533886) == 8 then
			player.Team = Security
      player.CharacterAdded:Connect(function(char)
      	char:WaitForChild('Humanoid').WalkSpeed = 25
      end)
		end
  end
end)

1 answer

Well, I have not personally explored the group-related api that one uses when creating a game that tests for group stats, but based on 5 minutes of reading it seems that your checks for being in the group and having the rank are done correctly.

I'm also going to assume that you know how to open the output bar and test to see if there are any errors. If not this may help.

The one suggestion I can make, is to change up your Team setting method. I am aware that roblox added an alternative method to setting Teams rather then TeamColor, which you seem to be attempting to use, but since I haven't bothered to learn much about it I'm just going to assume that you might be using it wrong (Since there is no other possible source of error visible).

That's why I'm going to show you how to set Teams using a more old-fashioned method which, according to the roblox wiki, won't ever depreciate. You can start by gathering the names for each Team's color.

Once you've done that you have multipe ways of accomplishing this goal. Since you already have variables set up for both of your teams we can go with the variable method. Start by setting each of your variables to the BrickColor of the respective team. Or you can just copy this:

local HRs = BrickColor.new("TheExactNameOfTheColor")
local Security = BrickColor.new("TheExactNameOfTheColor") 

If your not sure what the exact color is navigate to the team under the 'Teams' folder which is right under the 'StarterPlayer' folder. If there is no team folder, that might be the problem. If there is, and both teams are there, click on them and open the property window (This can be found under the 'VIEW' tab, just like the output window). The TeamColor will be listed under the first section of properties, with the respective color name to the right of it. That exact name(Capitalization counts) should be put inside the respective variables I made for you.

Now that you have the variables set, you can go ahead and put the team change in the script. In order to change a player's teamcolor using this method you must do something that looks a little like this:

Player.TeamColor = BrickColor.new("Dark stone grey") --Just an example

But since you have variables set you can put this in your script:

player.TeamColor = HRs

If your script still doesn't work then it's probably because of something not shown in your question.

Hope this helps!

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