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

Is it possible to put parameters in events like MouseEnter?

Asked by 9 years ago

Hello.

I want to ask if it is possible to put parameters in event functions like MouseEnter.

For instance, take this MouseEnter script:

function Gr8()

end

game.Players.LocalPlayer.PlayerGui.JusticeEndo.MouseEnter:connect(GR8);

How could you put parameters into something like that!? Is that possible using this method? Are there other methods? Please help, thanks.

0
What do you mean by "put parameters"? Explain what you are trying to accomplish. BlueTaslem 18071 — 9y
0
I want to accomplish this: function PrintStuff(x) <--- The x inside parenthesis is the PARAMETER. However, I want to do it with an event. Arithmeticity 167 — 9y
0
The arguments supplied by an event are defined by the implementation of that event in the ROBLOX API. There is no way to modify how such events behave, including what data they send as arguments. duckwit 1404 — 9y
0
So we cannot add parameters into the event huh? Arithmeticity 167 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

Just run the function in an anonymous function passed to the event (Nested Functions).

local function bork(one,two)
print(one.." slipped on a "..two.."!")
end

game.Players.PlayerAdded:connect(function(player) --anonymous function fired when player is added, with player passed as an argument
bork(player.Name,"banana") ------------------> "Arithmeticity slipped on a banana!"
end)
Ad
Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Like duckwit said, you can't directly pass in 'extra' arguments, but you can do this:

function foo(bar)
    print(bar)
end

game.Players.LocalPlayer.PlayerGui.JusticeEndo.MouseEnter:connect(function()
    foo("FOR DAMACIA!")
end)
0
I solved the problem, and thank you! To solve the problem: I used two functions, the MouseEnter event would fire and go into one function which in turn goes into another function to activate the effect(s). Arithmeticity 167 — 9y

Answer this question