Team Kick Command

Are you sure your typing in the command ‘/Remove %1’ in the chat

Yes, I am completly sure. (: …

1 Like

Like with the capital, space and %1?

You used the name canKick twice:

for i, canKick in pairs canKick do

Instead, use:

for i, playerToKick in pairs canKick do

And replace all references that were mentioning the current player to playerToKick

Yes! Exactly as it should… <3 …

1 Like

I will try this out right now.!

The script still isn’t working.

local canKick = {“ItsKoolYT”}
game.Players.PlayerAdded:Connect(function(Player)
for i, playerToKick in pairs(canKick) do
if Player.Name == canKick then
Player.Chatted:Connect(function(Message)
if Message == “/Remove %2” then
local Team = game:GetService(“Teams”):WaitForChild("%1")
for _, Team in pairs(Team) do
local players = Team:GetPlayers()
players:Kick(“:trophy: | 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)

Few mistakes in the code, I fixed them:

local TeamName = "" --Put the team name here!
local canKick = {'ItsKoolYT'}
game.Players.PlayerAdded:Connect(function(Player)
for i, playerToKick in pairs(canKick) do
if table.find(canKick, Player.Name) then
Player.Chatted:Connect(function(Message)
if Message == "/Remove %2" then
local Team = game:GetService("Teams"):WaitForChild(TeamName)
for _, Team in pairs(Team) do
local players = Team:GetPlayers()
for _, playerToKick in ipairs(players) do
playerToKick:Kick(":trophy: | 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)

You have another one of those in your team loop, just noticed that.

I haven’t read this thread, so I don’t know everything everyone is saying, but I figured I might be able to help out with what you want. I just tested both of these in studio, and they’re both working.

Kick the same team every time
local canKick = {"ItsKoolYT", "Zyrun"}
local teamToKick = game:GetService("Teams"):WaitForChild("%1")
--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 (string.lower(Message) == "/remove %1") then
					
					for _, playerToKick in ipairs(teamToKick:GetPlayers()) do
						playerToKick:Kick("🏆 | Training has concluded, and you have passed. You have all been ranked! Thanks for attending Training! - ItsKoolYT | Head of Operations | ☆")
					end
					
					--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)
Kick a specified-in-chat-command team
-- // If you're looking to kick a specified-in-chat team
-- // https://developer.roblox.com/en-us/api-reference/lua-docs/string

local canKick = {"ItsKoolYT", "Zyrun"}
local prefix = "/" 
local kickCommand = "remove" -- // This must be lowercase, but you'll be able to chat in uppercase or however you want
local TeamService = game:GetService("Teams")

game:GetService("Players").PlayerAdded:Connect(function(Player)
	for _, canKick in pairs(canKick) do
		if (Player.Name == canKick) then
			Player.Chatted:Connect(function(Message)
				Message = string.lower(Message)
				local prefixLength = string.len(prefix)
				if (string.sub(Message, 1, prefixLength) == string.lower(prefix)) then -- // If the start of the message is the prefix
					
					local command = string.sub(Message, prefixLength + 1)
					local splitBySpaces = string.split(command, " ")
					if (splitBySpaces[1] == kickCommand) and (splitBySpaces[2]) then -- // If we're using the kick command
						local teamToKick
						for _, team in ipairs(TeamService:GetChildren()) do
							if (string.sub(string.lower(team.Name), 1, string.len(splitBySpaces[2])) == splitBySpaces[2]) then
								teamToKick = team
								break
							end
						end
						
						if (teamToKick) then
							local playersToKick = teamToKick:GetPlayers()
							for _, playerToKick in ipairs(playersToKick) do
								playerToKick:Kick("🏆 | Training has concluded, and you have passed. You have all been ranked! Thanks for attending Training! - ItsKoolYT | Head of Operations | ☆")
							end
							
							print("Kicking", #playersToKick, "player(s) with the kick team command!")
						else
							print("Used the kick team command, but I couldn't find the specified team")
						end
					end
					
				end
			end)
		end
	end
end)

Oops, forgot to include the string manipulation link for the second solution if you want to know how it’s done. Best of luck to you!