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 player's team change when they say something?

So I am making this thing for a group. I wanted to make a thing, where if you say "DevSpecial" or something, you are put into the dev team. I am having problems line 14-15 (in studio it is line 24-25)

18:56:38.974 - Teams is not a valid member of Teams 18:56:38.991 - Script 'Workspace.Script', Line 25 18:56:38.992 - Stack End

local group = {
	["JohnTDev"] = true;					
	["JohnTUnderwood"] = true;			
	["littejo29"] = true;						
	["Player"] = true; 						
}
 
game.Players.PlayerAdded:connect(function(player)
	if group[player.Name] then 
		player.Chatted:connect(function(msg)
			if msg == "DevSpecial" then
				local character = game.Workspace:FindFirstChild(player.Name) and game.Teams
				local Teams = game.Teams
				if character.Teams == "{Officers}" or "{Trainees}" or "{Jedi Order}" then
					character.Teams= "{Dev Team} (SPECIAL)"
					character:FindFirstChild("Humanoid").Health = 0
				end
			end
		end)
	end
end)

What do I do? Youtube and the wiki aren't helping me find what I want.

1 answer

✓ Accepted answer

First, you don't need to reference the player's character in order to change their team. Take out local character = game.Workspace:FindFirstChild(player.Name) and game.Teams.

Take out local Teams = game.Teams.

To check for the team, do:

for i,v in pairs(game.Teams:GetChildren()) do
	if v.TeamColor == player.TeamColor then
		if v.Name == "{Officers}" or v.Name == "{Trainees}" or v.Name == "{Jedi Order}" then
			player.TeamColor = BrickColor.new("") --Put the team color of the Developer's team here
			player:LoadCharacter() --Better than to kill them
		end
	end
end

4 comments

0

Sorry for the late response. Is it suppose to be like this?

0

game.Players.PlayerAdded:connect(function(player) if group[player.Name] then player.Chatted:connect(function(msg) if msg == "DevSpecial" then for i,v in pairs(game.Teams:GetChildren()) do if v.TeamColor == player.TeamColor then if v.Name == "{Officers}" or v.Name == "{Trainees}" or v.Name == "{Jedi Order}" then player.TeamColor = BrickColor.new("Black") player:Lo

0

player:LoadCharacter() end end end end end) end end)

0

yes

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