Sorry for being annoying I need a bit of help with my kick command, every time I type “kick all” it adds another reason like first player sees “kicked for hello” second player sees “kicked for hello hello” exp;
local prefix = "/"
local players = game:GetService("Players")
function GetPlayerFromServer(Player,String)
local Found = {}
local strl = String:lower()
if strl == "all" then
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
table.insert(Found,v)
end
elseif strl == "others" then
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Name ~= Player.Name then
table.insert(Found,v)
end
end
elseif strl == "me" then
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Name == Player.Name then
table.insert(Found,v)
end
end
else
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Name:lower():sub(1, #String) == String:lower() then
table.insert(Found,v)
end
end
end
return Found
end
players.PlayerAdded:Connect(function(plr) -- getting the player that joined the server
plr.Chatted:Connect(function(msg)
local split = string.split(msg," ")
-- cutting the table into segmants by a letter " "
-- checking to see if they said the command
if string.lower(split[1]) == prefix.."kick" then -- /kick
local reason = ""
-- remember this? We are going to change this now.
-- the 1st parameter is the local player (You) and the 2nd parameter is a string
for _,Player in ipairs(GetPlayerFromServer(plr,split[2])) do
for i,v in pairs(split) do -- Getting all the seperated parts of the table
if i == 1 or i == 2 then -- 1 is the [command we said] /kick and 2 is the [player's name we said] victim
else
reason=reason.." "..split[i] -- We are combining the words back together after cutting them but removing 2 words
end
end
if reason == "" then
Player:Kick("You have been kicked by "..plr.Name.." for: no reason")
else
Player:Kick("You have been kicked by "..plr.Name.." for: "..reason)
end
end
end
end)
end)
the whole code.