Still does not work after one second
This works when the script is running, but we need something that works while in studio.
Try parenting the plugin to an Actor
.
I have never done that (as I said Iâm new to plugins), how do I do it?
Just parent them to an Actor
model instead of a folder. This will start them in parallel.
Looks like the plugin didnât load at all. Probably just another studio issue.
I actually have never tried parenting anything to a plugin script before, so this is new to me. Try restarting studio and enabling plugin debugging.
Still no error or anything, not sure how to enable plugin errors.
I wish i could help this topic more but i do not know Enough about scripting.
Itâs not that. I actually have no idea what could possibly be causing this, Iâm curious myself.
Anything wrong with the script?
task.wait(1)
local Load = require(script.StringLoader)
local SES = game:GetService("ScriptEditorService")
local toolbar = plugin:CreateToolbar("Nerd Script Helper")
local NewButton = toolbar:CreateButton("đ¤", "owo", "http://www.roblox.com/asset/?id=10218508810")
NewButton.Click:Connect(function()
for i, v in ipairs(game:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") then
v:GetPropertyChangedSignal("Source"):Connect(function()
local succ, err = pcall(function()
Load(v.Source)
end)
if not succ then warn(err) end
end)
end
end
end)
You should be using pairs
instead of ipairs
. I also think that you should disconnect the connections after it is clicked again to prevent memory leaks.
Smart idea i will bookmark this to remember if i make a plugin
Now why is it not working?
task.wait(1)
local Load = require(script.StringLoader)
local SES = game:GetService("ScriptEditorService")
local toolbar = plugin:CreateToolbar("Nerd Script Helper")
local NewButton = toolbar:CreateButton("đ¤", "owo", "http://www.roblox.com/asset/?id=10218508810")
local db = true
local conn
NewButton.Click:Connect(function()
if db == true then
db=false
conn = function()
for i, v in pairs(game:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") then
v:GetPropertyChangedSignal("Source"):Connect(function()
local succ, err = pcall(function()
Load(v.Source)
end)
if not succ then warn(err) end
end)
end
end
end
conn()
else
db = true
conn = nil
end
end)
I donât really know. Iâd try doing GetDescendants as soon as the script starts and after the variables are assigned for testing.
So I looked through several documents and wasnât able to find anything about an actual script error from the editor, however there is an instance called ScriptDocument which represents the open script editor. Thinking you could use this with loadstring, loadstring the scriptâs source (retrieved from GetLineCount() + GetLine()'ing each line concatenated with \n as a separator), then examine the error message and see what the error is.
You donât have to pcall loadstring as it returns nil and the error message as the second argument if the source wasnât loaded properly. So, doing loadstring(âaâ) returns nil, â[string âaâ]:1: Incomplete statement: expected assignment or a function callâ as a string, not an error message. If you want errors from the scriptâs source (eg. attempt to index nil with _, attempt _ is not a valid member of _, etcâŚ), you can pcall the function returned from loadstring.
So,
local func, errorMessage = loadstring(someString)
if func then
local success, result = pcall(func)
if success then
-- script was run successfully
end
else
-- script has some error that prevents it from being compiled
end
However do be aware that this can become CPU intensive and likely will cause a memory leak if you donât structure your code in a certain way (returning connections from the function that loadstring returns/not using a module), or unless you are very good at sandboxing as the connections arenât able to be managed externally afaik (no way to get a table of connected connections without another module), so do be conscious of that.
You can get a ScriptDocument that represents the currently open script editor from the ScriptEditorService: