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

attempt to index global 'script' (a nil value)?

Asked by 5 years ago
Edited 5 years ago

Working on a plugin which saves what you type (It's a notepad plugin)

local dockWidget = plugin:CreateDockWidgetPluginGui (
    "Notepad - FernandoMacLeod",
    DockWidgetPluginGuiInfo.new (
        Enum.InitialDockState.Float,
        true,
        true,
        300,
        200,

        150,
        100
    )
)

local ui = script:WaitForChild("UI")
local container = ui:WaitForChild("Container")
local body = container:WaitForChild("Body")

local notepad = body:WaitForChild("Notepad")
local errorLabel = body:WaitForChild("Error")
local success = body:WaitForChild("Success")

local savedText = ""
function save ()
    plugin:SetSetting("Notepad" .. tostring(game.GameId), notepad.Text)
end

notepad.Parent = dockWidget
dockWidget.Title = "Notepad"

while (game.GameId == 0) do wait(0.3) end
savedText = plugin:GetSetting("Notepad" .. tostring(game.GameId)) or ""
errorLabel.Visible = true

notepad.FocusLost:Connect( save )

Never had this error before whilst testing a plugin. I've tried to look at other threads to do with this issue, but to no avail.

Line causing the error:

local interface = script:WaitForChild("UI")

0
Chipio has pretty good tutorials huh, also you're trying to index a whole UI inside a script, did you mean to do script.Parent? What you're doing is trying to find frames that are descendants of the current script. YabaDabaD0O 505 — 5y
0
I agree, Chipio does have good tutorials. No, I didn't mean to do script.Parent ( even though I've tried that ). The parent of the Gui is inside the scrip, I've always placed my Gui's inside plugin scripts, this is the first time I'm only getting the error now. Morgan_Smyth 0 — 5y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago

This seems to be a new problem that various users have experienced recently (including myself). Instead of accessing objects through the keyword script, you now must use the keyword plugin instead and retrieve objects from there. For example, if you upload the script as the plugin with the objects inside, you can go:

local ui = plugin["ScriptNameHere"].UI

to retrieve the UI. However, for a more organised layout, I would recommend uploading a folder as the plugin with the script and the rest of the contents inside, so you don't have to go through the script to get everything, although it should work fine either way.

Ad

Answer this question