Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't my function seem to register?

I'm attempting to make the simplest of functions that hides the relevant screen gui labels and buttons but I can't even get that to work.

function BPressed(Button)
	Button.Visible = false
	Button.Parent.Visible = false
end

script.Parent.OpenMenu.Battle.MouseButton1Down:Connect(BPressed(script.Parent.OpenMenu.Battle))

Whenever I try to test it instead of connecting the function it just executes the function and gives me the error "Attempt to connect failed: Passed value is not a function"

Is something the matter with my script? What's going on?

1 answer

✓ Accepted answer

You can't specify arguments to a callback, only the signal can. If you wish to execute the function with arguments, you'll have to wrap it in an anonymous function to replace the callback.

MouseButton1Down:Connect(function()
	BPressed(--[[Button Path]])
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.