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

Parameters in connection lines?

Is there any way to use parameters inside of a connection line? For example, if I had a function like this:

function awesomesupercoolfunction(parameter)
	print("Wow, " ..parameter .." is great.")
end

And I wanted it to fire on a MouseEnter event,

creativenameforabutton.MouseEnter:connect(awesomesupercoolfunction)

or something like that, how would I go about doing this?

I tried

creativenameforabutton.MouseEnter:connect(awesomesupercoolfunction(parameter))

just in case it was that simple, but it wasn't. Is there any way to do this? I can accomplish what I want to do without it, it would just make the process much more simple. Any help would be appreciated!

1 comment

0

Le comment, I hope I was right to pick this.

1 answer

✓ Accepted answer

Connect a new function

I know, it's not convenient, but it's the only way you're going to be able to give a generic function like that access to things like closures from inside a connection line.

MouseEnter:connect(function()
return mySuperAwesomeFunc(thatParameterYouAlwaysWanted)
end);

1 comment

0

Ah, darn. That's what I meant when I said I could do it without it. Well, thanks anyhow!

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