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

Chat Command Script Player Finder Error?

Asked by 6 years ago

I made this chat command script but when I say all others or a part of a players name it does nothing. It used to work. I have no clue what to do. The output says that there are no errors. Can someone please help me?

local Prefix = "!"
local Prefixlen = string.len(Prefix)
local Players = game.Players:GetPlayers()

function kick(message, player)
    local commandlen = 4
    local sub = ""
    sub = string.sub(message, Prefixlen + 2 + commandlen)
    sub = string.lower(sub)
    if sub == "all" then
        for i,v in ipairs(Players) do
            v:Kick()
        end
    elseif sub == "others" then
        for i,v in ipairs(Players) do
            if not v.Name == player.Name then
                v:Kick()
            end
        end
    elseif sub == "me" then
        player:Kick()
    else
        for i,v in ipairs(Players) do
            local one = ""
            one = string.sub(Players[i].Name, 1, 1)
            local two = ""
            two = string.lower(one)
            local subdown = ""
            subdown = string.lower(sub)
            local three = nil
            three = string.match(subdown, two.."%w+")
            if three == nil then
                wait()
            else
                v:Kick()
            end
        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.lower(string.sub(message, 1, Prefixlen + 4)) == Prefix.."kick" then
            kick(message, player)
        end
    end)
end)

Answer this question