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

I've made a admin and dont know what to put in the game.Players bit? [Solved]

Asked by 4 years ago
Edited by Ziffixture 4 years ago

Here is the code

commands.kick = function(sender, arguments)

    print("Kick Fired By "..sender.Name)

    for _, playerName in pairs(arguments) do
        print(playerName)
    end

    local playerToKick = arguments[1]

    if playerToKick then
        local plrToK = findPlayer(playerToKick)

        if plrToK then
            game.Players.    :Kick("Removed From The Server")
            print("Successfully Removed Player!")
        end
    end

end

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message,recipient)
        if isAdmin(player) then
            message = string.lower(message)

            local splitString = message:split(" ")

            local slashCommand = splitString[1]

            local cmd = slashCommand:split(prefix)

            local cmdName = cmd[2]

            if commands[cmdName] then

                local arguments = {}

                for i = 2, #splitString, 1 do
                    table.insert(arguments,splitString[i])
                end

                commands[cmdName](player,arguments)

            end


        end
end)
    end)


local function findPlayer(name)

    for _, player in pairs(game.Players:GetPlayers()) do
        if string.lower(player.Name) == name then
            return player
        end
    end

    return nil

end

local function isAdmin(player)
    for _, v in pairs(admins) do
        if v == player.Name then
            return true
        end
    end

   return false
end

1 answer

Log in to vote
0
Answered by 4 years ago

This question has been solved by the original poster.

game.Players[playerToKick]:Kick("")

Figured it out

Ad

Answer this question