Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Could someone help me with this messed up kill command?

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

0

No one?

0

Eh. My friend is looking into it. Hopefully someone can beat him to the fix.

0

is Args[1] the command? If it is then you're searching to match the wrong string.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.