I’ve been trying to make a cd command for a plugin that acts like a console for roblox studio, just one problem. Every time I run cd StarterGui or cd .. the script spams this error and almost crashes my studio.
07:55:45.146 The current identity (5) cannot Class security check (lacking permission 6) - Studio - cd:47
07:55:45.147 Stack Begin - Studio
07:55:45.147 Script 'user_lua.console.rbxmx.lua.console.PluginManager.Commands.cd', Line 47 - function changeDir - Studio - cd:47
07:55:45.147 Script 'user_lua.console.rbxmx.lua.console.PluginManager.Commands.cd', Line 107 - Studio - cd:107
07:55:45.147 Script 'user_lua.console.rbxmx.lua.console.PluginManager', Line 97 - Studio - PluginManager:97
07:55:45.147 Stack End - Studio
I am not really getting what it means. I am able to do cd Workspace and have it work, but other than that, everything else gives me this error. I don’t know what I am doing wrong and I have tried this post, but even after wrapping stuff in pcalls it kept giving this error.
Main Function Inside Module Script
--|| VARS ||--
local command = {}
local currentDir = game
--|| FUNCTIONS ||--
local function printDir()
local children = currentDir:GetChildren()
for i = 1, #children do
local ok, service = pcall(function()
return children[i]
end)
if ok then
print(children[i].Name)
end
end
end
local function changeDir(input, consoleUI)
if input == ".." then
if currentDir == game then
local newResponse = script.Parent.Assets:WaitForChild("Response"):Clone()
if consoleUI.Assets:FindFirstChild("Response") then
consoleUI.Assets.Response.Name = "OldResponse"
end
newResponse.Parent = consoleUI.Assets
newResponse.TextColor3 = Color3.new(0.929992, 0.718502, 0.698558)
newResponse.Name = "Response"
newResponse.Text = "ERR: cannot go above the game root"
return
else
currentDir = game
printDir()
return
end
end
local foundChildDir = nil
for _,v in pairs(currentDir:GetChildren()) do
if string.match(v.Name, input) then -- Line 47, main problem here I guess
foundChildDir = v
break
end
end
if foundChildDir ~= nil then
currentDir = foundChildDir
printDir()
return
end
local newResponse = script.Parent.Assets:WaitForChild("Response"):Clone()
if consoleUI.Assets:FindFirstChild("Response") then
consoleUI.Assets.Response.Name = "OldResponse"
end
newResponse.Parent = consoleUI.Assets
newResponse.TextColor3 = Color3.new(0.929992, 0.718502, 0.698558)
newResponse.Name = "Response"
newResponse.Text = "ERR: no such directory"
return
end
-- Down here is the command handler but that isn't important for this.
If anyone could help that’d be greatly appreciated
Why are you using this useless loop? You are aware that FindFirstChild exists, correct?
for _,v in pairs(currentDir:GetChildren()) do
if string.match(v.Name, input) then -- Line 47, main problem here I guess
foundChildDir = v
break
end
end
Ok cool, so I can’t CD into StarterGui or StarterPlayer, other wise it gives the same error on line 47.
Is there a way to catch this error? So if the player tries to cd into one of these areas where it can’t go, it’ll just stop it and return a message?
for _,v in pairs(currentDir:GetChildren()) do
if string.match(v.Name, input) then -- Line 47, main problem here I guess
foundChildDir = v
break
end
end
Sorry, not good with this kinda stuff, only know it from .catch() in JS.
if currentDir:FindFirstChild(input) then
foundChildDir = currentdir:FindFirstChild(input) -- Would be a instance, not an string
end
It’s surprising how many developers don’t know the basic behavior of Instance functions. It takes a glance at the developer hub to see what each function returns.