Hello.
I want to ask if it is possible to put parameters in event functions like MouseEnter.
For instance, take this MouseEnter script:
1 | function Gr 8 () |
2 |
3 | end |
4 |
5 | game.Players.LocalPlayer.PlayerGui.JusticeEndo.MouseEnter:connect(GR 8 ); |
How could you put parameters into something like that!? Is that possible using this method? Are there other methods? Please help, thanks.
Just run the function in an anonymous function passed to the event (Nested Functions).
1 | local function bork(one,two) |
2 | print (one.. " slipped on a " ..two.. "!" ) |
3 | end |
4 |
5 | game.Players.PlayerAdded:connect( function (player) --anonymous function fired when player is added, with player passed as an argument |
6 | bork(player.Name, "banana" ) ------------------> "Arithmeticity slipped on a banana!" |
7 | end ) |
Like duckwit said, you can't directly pass in 'extra' arguments, but you can do this:
1 | function foo(bar) |
2 | print (bar) |
3 | end |
4 |
5 | game.Players.LocalPlayer.PlayerGui.JusticeEndo.MouseEnter:connect( function () |
6 | foo( "FOR DAMACIA!" ) |
7 | end ) |