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

Why is my function not being recognized?

Asked by 5 years ago

(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
1
MouseButton1Down passes the X and Y coordinates of the mouse. You can't just add any parameter because you feel like it. User#19524 175 — 5y
1
you don't need a parameter in your 'Sections.Features.MouseButton1Down:connect(SectionOpener(Sections.Features))' , and 'local function SectionOpener(Textbox)' User#17685 0 — 5y
0
@incapaz Realized that. I resorted to Sections.Features.MouseButton1Down:connect(function() <new line> SectionOpener(Sections.Features) <new line> end). thx ninja_eaglegamer 61 — 5y

Answer this question