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

Enabling Developer Console for only a certain list of people?

Asked by 7 years ago

This is a localscript in StarterGui. This basically sees if a player is allowed to see the Developer Console from the whiteList and then if the player is allowed then the Developer Console is enabled and if not, it's disabled.

local player = game:GetService("Players").LocalPlayer
local starterGui = game:GetService("StarterGui")

local whiteList = {
        "Precisionly",
        "killzone45671",
        "CommanderSkywalkerTR",
        "Versatrax",
        "Tragedy_Blue",
        "DcMultiVerseParadox",
    }

game["Run Service"].RenderStepped:wait()
if starterGui:GetCore("DeveloperConsoleVisible") then
    if not whiteList[player.Name] then
        starterGui:SetCore("DeveloperConsoleVisible", false)
    end
end

1 answer

Log in to vote
1
Answered by 7 years ago

You can't check if something is part of a table like that. You'll have to write a function that loops through the table, and matches any values with those inside the table.

It'll look something like this:

local function FindValueInTable(tbl, val)
    for _,v in next, tbl do
        if v == val then
            return true
        end
    end
    return false
end

Also you'll need to put a loop on making the DeveloperConsole visible.

local plr = game.Players.LocalPlayer
local gui = game.StarterGui

local whitelist = {
    "AlreadyPro"
}

local function FindValueInTable(tbl, val)
    for _,v in next, tbl do
        if v == val then
            return true
        end
    end
    return false
end

game:GetService("RunService").RenderStepped:Connect(function()
    if FindValueInTable(whitelist, plr.Name) then
        return
    elseif gui:GetCore("DeveloperConsoleVisible") then
        gui:SetCore("DeveloperConsoleVisible", false)
    end
end)
0
On line 9, would "for i,v in pairs(tbl) do" work? FiredDusk 1466 — 7y
0
Yes, but next is faster than pairs and looks neater. AlreadyPro 153 — 7y
Ad

Answer this question