Variable not working when its there?

Hello, I have a variable showing where it is and it is not working.

Heres the variable:

local InterfaceUi = script.Interface

Heres where it is:

Have you tried?

local InterfaceUi = script:WaitForChild("Interface")
1 Like

I get this error or warning

This is a plugin right?

If you save the plugin as a lua file then it obviously won’t work. I know that it’s obvious but just in case that you have done that

Also, how does it “not work”?

Oh I have done this before and it has worked also its in a folder so its rbxm not lua file also I forgot to provide the output:

You should print the children:

table.foreach(script:GetChildren(), print)

Make sure that you don’t set the parent of Interface previously in the script. You also should provide more context, local InterfaceUi = script.Interface isn’t enough.

It seems like there is more code before the error, because the error was on line 24. Something must have went wrong previously.

Should I not put the ui in the script also heres the full code:

local toolbar = plugin:CreateToolbar("Badge+ (" .. script.Data.Version.Value .. ")") -- Creates toolbar with name specified in brackets
local ToolbarButton = toolbar:CreateButton ("Open Menu", "Opens Badge+ main menu", "rbxassetid://9322595392") -- [Buttons name, Buttons description, Buttons Image ID]
local PluginInterface = script.Interface
PluginInterface.Parent = game.CoreGui

	PluginInterface.Enabled = not PluginInterface.Enabled

-- // Services

-- // Plugin Variables
local DataFoler = script.Data
local ModulesFolder = script.Modules
local ResourcesFolder = script.Resources

-- // Interface Variables

local InterfaceUi = script.Interface
local InterfaceModule = require(ModulesFolder.InterfaceModules.InterfaceHandler)
local BackgroundFrame = InterfaceUi.Background
local HomeFrame = BackgroundFrame.Home
local BadgesFrame = BackgroundFrame.Badges

-- // HomeFrame Variables
local BadgesButton = HomeFrame.BadgesButton
local SettingsButton = HomeFrame.SettingsButton
local UpdatesButton = HomeFrame.UpdatesButton

-- // BadgesFrame Variables
local HomeButton = BadgesFrame.HomeButton
local BadgesListFrame = BadgesFrame.BadgesList
local WelcomeBadgeButton = BadgesListFrame.WelcomeBadge
local TimeBadgeButton = BadgesListFrame.TimeBadge
local PromptBadgeButton = BadgesListFrame.PromptBadge
local PartBadgeButton = BadgesListFrame.PartBadge
local GroupBadgeButton = BadgesListFrame.GroupBadge
local GamepassButton = BadgesListFrame.GamepassBadge
local DiedBadgeButton = BadgesListFrame.DiedBadge
local CreatorBadgeButton = BadgesListFrame.CreatorBadge
local ClickBadgeButton = BadgesListFrame.ClickBadge
local ChatBadgeButton = BadgesListFrame.ChatBadge

-- // Badges Variables
local BadgesFolder =  ResourcesFolder.Badges
local WelcomeBadge = BadgesFolder.WelcomeBadge
local TimeBadge = BadgesFolder.TimeBadge
local PromptBadge = BadgesFolder.PromptBadge
local PartBadge = BadgesFolder.PartBadge
local GroupBadge = BadgesFolder.GroupBadge
local GamepassBadge = BadgesFolder.GamepassBadge
local DiedBadge = BadgesFolder.DiedBadge
local CreatorBadge = BadgesFolder.CreatorBadge
local ClickBadge = BadgesFolder.ClickBadge
local ChatBadge = BadgesFolder.ChatBadge


-- // HomeInterface

	BadgesFrame.Visible = true
	HomeFrame.Visible = false

It’s right here, you set its parent to CoreGui. It’s already a variable with the name PluginInterface, so you don’t need that variable called InterfaceUi.

Edit: Actually, you can just change the local InterfaceUi = script.Interface into local InterfaceUi = PluginInterface