Team Kick Command

Hello! So I created a Team Kick Command, where if a Whitelisted person says the command, it will kick the players in the team! So example: /Remove %1 would remove all the players from that team percent. There’s no errors, however, the script isn’t kicking the players on that team. Please help!

Script:

local canKick = {"ItsKoolYT"}
local Team = game:GetService("Teams"):WaitForChild("%1")

game.Players.PlayerAdded:Connect(function(Player)
	for _, canKick in pairs(canKick) do
		if Player.Name == canKick then
			Player.Chatted:Connect(function(Message)
				if Message == "/Remove %1" then
						local team = game:GetService("Teams"):GetTeams(Te)
								for _, team in pairs(team) do
									local players = team:GetPlayers()
								if Player.TeamColor == BrickColor.new(("Daisy orange")) then
							players:Kick("🏆 | Training has concluded, and you have passed. You have all been ranked! Thanks for attending Training! - ItsKoolYT | Head of Operations | ☆")
						end
					end
				end
			end)
		end
	end
end)

Edit: There is one error.

Where do you define TE? currently I believe it’s nil which is why the loop is erroring.

You haven’t specified which team to kick the player from. GetTeams() doesn’t take any parameters, yet you have defined “Te”. GetTeams() just returns an array of all the teams in the game.

1 Like

Oops. That’s something I messed up. I will fix it and get back to you.

No errors this time, however it is still not working. :thinking:

Yes, “Te” was a mistake I made. It was supposed to be Team. I fixed it, however it still is not working.

Is %1 a team or a bunch of teams? If so, getTeams is useless here and should be Team:GetPlayers() as that’ll return an array with all the players.

(text so i can send this) %1 is a team. (:

You don’t need to define team then. You can simply use your old Team variable and get the players inside of that and use the loop to go through that instead.

Oh, okay. I’m not the best at scripting, however I’ll get back to you with the results,

Which team variable by the way?

local Team = game:GetService("Teams"):WaitForChild("%1")

I’d recommend you don’t use reuse variable names as it gets confusing as seen in this situation.

Okay, thank you. I will do this, should I replace

local team = game:GetService(“Teams”):GetTeams(Team)

with local team = game:GetService(“Teams”):GetTeams(%1) ??

Why are you using teams, since it always kicks Daisy orange, if it is intended to kick Daisy orange, do this:

local canKick = {"ItsKoolYT"}
local Team = game:GetService("Teams"):WaitForChild("%1")

game.Players.PlayerAdded:Connect(function(Player)
	for _, canKick in pairs(canKick) do
		if Player.Name == canKick then
			Player.Chatted:Connect(function(Message)
				if Message == "/Remove %1" then
									local players = game.Players:GetPlayers()
								if Player.TeamColor == BrickColor.new(("Daisy orange")) then
							Player:Kick("🏆 | Training has concluded, and you have passed. You have all been ranked! Thanks for attending Training! - ItsKoolYT | Head of Operations | ☆")
						end
					end
			end)
		end
	end
end)

No they said to replace it with:

local Team = game:GetService("Teams"):WaitForChild("%1")

You cannot kick a table of players.

1 Like

Sorry, I made a typo in the code, it’s now fixed.

1 Like

I’m trying the script currently.

1 Like

The script did not work, and it’s errorless.