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

Parameters in connection lines?

Asked by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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!

0
Le comment, I hope I was right to pick this. Vingam_Securis 213 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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);
0
Ah, darn. That's what I meant when I said I could do it without it. Well, thanks anyhow! Pyrondon 2089 — 8y
Ad

Answer this question