Hey. I’m a bit new to modules, and I’m having some issues getting an array from a module with require. I keep getting “Requested module experienced an error while loading” errors. anyone have any suggestions? I’ll specify if requested.
module:
local list = {}
plr = game:GetService("Players").LocalPlayer
gui = plr.PlayerGui
screen = gui.Title.Frame
MenuButtons = {
screen.start,
screen.options,
screen.credits
}
list.Get = function()
return MenuButtons
end
return list
First of all, I know less python than I do lua. second, please be respectful. I’m trying my best, and I’ve been blissfully unaware of scripting standards this whole time.
Your error indicates that menu.ShowButtons is a nil value not a function value. You need to make sure menu.ShowButtons points to a function value before attempting to call it.
This post has a solution now, but yes I am curious why it doesn’t give me an autofill option.
(Also maybe I’ll put a boolean in there and delete the bottom function, because they have the same code lol…)
local menu = {
ShowButtons = function(buttons, speed, stopTime, targetX)
for i in buttons do
yScale = buttons[i].Position.Y.Scale
uiButtons.ShowButton(buttons[i], speed, targetX, yScale)
task.wait(stopTime)
end
end,
HideButtons = function(buttons, speed, stopTime, targetX)
for i in buttons do
yScale = buttons[i].Position.Y.Scale
uiButtons.HideButton(buttons[i], speed, targetX, yScale)
task.wait(stopTime)
end
end
}
ts = game:GetService("TweenService")
uiButtons = require(script.Parent)
yScale = nil
return menu
Looking at your code, this should work perfectly fine. I’ve tested it (removing the code within the functions to prevent any errors) and it worked as intended.
Maybe you’re defining menu incorrectly here:
Like a switcheroo of two variables, but i highly doubt that. I’ve been looking at this code for like 10 minutes, I have no idea what the issue could be!
My best guess is that there might be some other code behind the scenes (the scenes being these code snippets) that may be causing this issue. You’ve correctly defined ShowButtons here.