Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Could someone help me with this messed up kill command?

Asked by
Regate 0
10 years ago

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)
0
No one? Regate 0 — 10y
0
Eh. My friend is looking into it. Hopefully someone can beat him to the fix. Regate 0 — 10y
0
is Args[1] the command? If it is then you're searching to match the wrong string. 1waffle1 2908 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Here, check out this thread, it may help with your question with the FindPlayer; http://wiki.roblox.com/index.php?title=Advanced_Admin_Commands I hope this helped!

Ad

Answer this question