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

Admin Script not working at all and doesn't print any errors?

Asked by 5 years ago

Hello, I've been recently working on an Admin Script that has worked fine until I added the Trello API to it, it's a Server Script located in ServerScriptService. I don't know what the issue is as it's printing nothing to show any sign of errors or warnings.

local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local kick = Instance.new("RemoteFunction", ReplicatedStorage)

local API = require(game:GetService("ServerScriptService"):WaitForChild("TrelloAPI"))
local BoardID = API:GetBoardID("Game: Inspired Bans")
local ListID = API:GetListID("Bans", BoardID)
local Banned = API:GetCardsInList(ListID)

local Admins = {
    {
        GroupId = 2969540;
        RankId = 248;
    };
}

local Prefix = "\\"
local Players = game:GetService("Players")
local Commands = {}

Commands.kick = function(Sender, Arguments)
    local Message = table.concat(Arguments, " ")
    if (Arguments == nil) then return end
    local Victim = Arguments[1];
    if Victim == "me" then
        Victim = Sender.Name
    end
    local Reason = Arguments[2];
    if (Arguments[2] == nil) then
        Reason = "No reason provided."
    end
    game:GetService("Players"):FindFirstChild(Victim):Kick(Reason)
end

Commands.ban = function(Sender, Arguments)
    local Message = table.concat(Arguments, " ")
    if (Arguments == nil) then return end
    local Victim = Arguments[1];
    if (Arguments[1] == nil) then return end
    local Reason = Arguments[2];
    if (Arguments[2] == nil) then
        Reason = "No reason provided."
    end
    game:GetService("Players"):FindFirstChild(Victim):Kick("You have been banned.")
    local NewCard = API:AddCard(Victim,Reason,ListID)
    NewCard()
end

Commands.speed = function(Sender, Arguments)
    local Message = table.concat(Arguments, " ")
    if (Arguments == nil) then return end
    local Victim = Arguments[1];
    if Victim == "me" then
        Victim = Sender.Name
    end
    local Speed = tonumber(Arguments[2]);
    if (Arguments[2] == nil) then
        Speed = 16
    end
    game:GetService("Players"):FindFirstChild(Victim).Character.Humanoid.WalkSpeed = Speed
end

local function checkBanned(name)
    local isBanned = false
    for i, v in pairs(Banned) do
        if v.name == name then
            isBanned = true
        end
    end
    return isBanned
end

local function IsAdmin(Player)
    for _, Admin in pairs (Admins) do
        print(Admin, Player)
        if type(Admin) == "table" then
            local Rank = Player:GetRankInGroup(Admin.GroupId)
            if Rank >= (Admin.RankId or 248) then
                return true
            end
        end
    end
    return false
end

local function ParseMessage(Player, Message)
    local PrefixMatch = string.match(Message, "^"..Prefix)
    if PrefixMatch then
        Message = string.gsub(Message, PrefixMatch, "", 1)
        local Arguments = {}

        for Argument in string.gmatch(Message, "[^%s]+") do
            table.insert(Arguments, Argument)
        end

        local CommandName = Arguments[1]
        table.remove(Arguments, 1)
        local CommandFunc = Commands[CommandName]

        if CommandFunc ~= nil then
            CommandFunc(Player, Arguments)
        end
    end
end

Players.PlayerAdded:Connect(function(Player)
    if checkBanned(Player.Name) then
        game:GetService("Players"):FindFirstChild(Player.Name):Kick("You have been banned.")
    end
    Player.Chatted:Connect(function(Message, Recipient)
        if not Recipient and IsAdmin(Player) then
            ParseMessage(Player, Message)
        end
    end)
end)

This is the full script because I don't know where the issue is contained.

0
Make a breakpoint at line 1 and see where it goes. If that works, make one at line 111 and update the thread with that information. pidgey 548 — 5y
0
It stops at Line 18 Warriorfoox 25 — 5y
0
What is line 18? Line 18 in this thread is a declaration of a table which will have no odd behavior. pidgey 548 — 5y
0
That's the last line the script reads and does not go past that Warriorfoox 25 — 5y

Answer this question