(Running on a local script)
I'm trying to make a function activated by clicking a text button but it gives this error:
17:10:12.374 - Attempt to connect failed: Passed value is not a function 17:10:12.375 - Stack Begin 17:10:12.375 - Script 'Players.ninja_eaglegamer.PlayerGui.ShopScreen.ShopBrain', Line 37 17:10:12.376 - Stack End
This is the code I used
Sections.Features.MouseButton1Down:connect(SectionOpener(Sections.Features))
I didn't mistype the function as when I left the SectionOpener's argument empty, this was the output:
17:15:53.524 - Players.ninja_eaglegamer.PlayerGui.ShopScreen.ShopBrain:24: attempt to index local 'TextBox' (a nil value) 17:15:53.525 - Stack Begin 17:15:53.525 - Script 'Players.ninja_eaglegamer.PlayerGui.ShopScreen.ShopBrain', Line 24 - local SectionOpener 17:15:53.526 - Script 'Players.ninja_eaglegamer.PlayerGui.ShopScreen.ShopBrain', Line 37 17:15:53.526 - Stack End
Here is the actual function if that helps
local function SectionOpener(TextBox)
if SectionOpen == false then
local TextBoxFolder = ItemsBackground:FindFirstChild(TextBox.Name)
for i, ImageButton in pairs(TextBoxFolder:GetChildren()) do
ImageButton.Visible = true
SectionOpen = true
end
else
local TextBoxFolder = ItemsBackground:FindFirstChild(TextBox.Name)
for i, ImageButton in pairs(TextBoxFolder:GetChildren()) do
ImageButton.Visible = false
SectionOpen = false
end
end
end

3 comments
MouseButton1Down passes the X and Y coordinates of the mouse. You can't just add any parameter because you feel like it.
you don't need a parameter in your 'Sections.Features.MouseButton1Down:connect(SectionOpener(Sections.Features))' , and 'local function SectionOpener(Textbox)'
@incapaz Realized that. I resorted to Sections.Features.MouseButton1Down:connect(function() SectionOpener(Sections.Features) end). thx