I've recently scripted an AI with a friend. He made this FindPlayer function, and the kill command, but every time we go into a game and do "Matrix, kill PLAYER", it kills everyone in the game. We don't know the error to this. It runs just fine. We have tried to fix this over and over.
We think the error may occur here:
function FindPlayer(GivenString)
local Chars = {}
if GivenString == "me" then
table.insert(Chars, Plr)
elseif GivenString == "all" or GivenString == "everyone" or GivenString == "everybody" then
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
table.insert(Chars, v)
end
else
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Name:sub(1, GivenString:len()):lower() == GivenString:lower() then
table.insert(Chars, v)
end
end
end
return Chars
end
or here:
AddCommand("Kill", "matrix, kill", function(arg)
Args = GetArgs(arg, " ")
KilledPlayers = {}
for i,v in pairs(FindPlayer(Args[1])) do
pcall(function()
table.insert(KilledPlayers, v.Name)
v.Character:BreakJoints()
end)
end
MakeChat("Killed player(s) " .. table.concat(KilledPlayers, ", ") .. ".")
end)

3 comments
No one?
Eh. My friend is looking into it. Hopefully someone can beat him to the fix.
is Args[1] the command? If it is then you're searching to match the wrong string.