My team command doesn't function

local admins = {"chrisgarfeyt","","","","","",""}
local command_prefix_required = false
local command_symbol = "_"
local command_prefix_symbol = ""
function GetPlayer(name)
	for i,v in pairs(game.Players:GetPlayers()) do
		if string.match(string.lower(v.Name),string.lower(name)) then
			return v
		end
	end
end
function GetTeam(name)
	for i,v in pairs(game:service("Teams"):GetTeams()) do
		if string.match(string.lower(v.Name),string.lower(name)) then
			return v
		end
	end
end
function IsAdmin(name)
	for i,v in pairs(admins) do
		if string.lower(name)==string.lower(v) then
			return true
		end
	end
	return false
end
function Added(plr)
	print(plr)
	if not IsAdmin(plr.Name) then
		return
	end
	plr.Chatted:connect(function(msg)
		print(msg)
		local is_command = false
		if command_prefix_required then
			if string.lower(string.sub(msg,1,4+#command_prefix_symbol))==command_prefix_symbol.."team" then
				is_command = true
			end
		else
			if string.lower(string.sub(msg,1,4))=="team" then
				is_command = true
			end
		end
		if is_command then
			print("Command")
			local args = {}
			local i = 1
			for s in string.gmatch(msg,"/%w+") do
				args[i] = string.sub(s,2)
				i = i + 1
			end
			local player = GetPlayer(args[1])
			local team = GetTeam(args[2])
			print(player,team,unpack(args))
			if type(player)=="userdata" and team then
				player.TeamColor = team.TeamColor
			elseif type(player)=="table" and team then
				for i,v in pairs(player) do
					v.TeamColor = team.TeamColor
				end
			end
		end
	end)
end
game.Players.PlayerAdded:connect(Added)
for i,v in pairs(game.Players:GetPlayers()) do
	Added(v)
end

Can you put it in code tags please?

How, I dont know where is that.

image

Also please add more into your description & edit your title to be easier to understand, also state if you have any errors or not.

What do you mean by “but dont go”?

I just put “:team chris blue” And literally dont chnge me of team.

1 Like

Were there any errors in the output?

No, all is good thats why I am posting here.

Please edit your post to use code tags please.

In the spaces what do to see spaces?

Just copy and paste the code in, then select all the code and then click on the code tags

All is done I put it.

Alright, can you explain what your issue is & where you think it’s going wrong please?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.