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

Is it possible to put parameters in events like MouseEnter?

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.

4 comments

0

What do you mean by "put parameters"? Explain what you are trying to accomplish.

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.

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.

0

So we cannot add parameters into the event huh?

2 answers

✓ Accepted answer

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)

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)

1 comment

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).

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