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

Event Listener (Event:Connect) without using Anonymous Functions ?

Asked by 7 years ago
1brick = script.Parent
2brick.Touched:connect(function(part)
3    print("test")
4end)

Is an example of an anonymous function. How would I use a pre existing function instead of writing down the function inline?

0
Please accept my answer if it solves your question. SebbyTheGODKid 198 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
1local function MyNormalFunction(part)
2    print("test")
3end
4brick = script.Parent
5brick.Touched:Connect(MyNormalFunction) -- :connect is deprecated, use :Connect instead.

easy-peesy

0
brick.Touced might not give you much, though.. :P protectiveebob 221 — 7y
0
he meant Touched, duh Gey4Jesus69 2705 — 7y
0
Thank you! In the Roblox wiki I never seen an example of an event that uses an already made function, they always use anon functions. Formidable_Beast 197 — 7y
0
No problem. SebbyTheGODKid 198 — 7y
Ad

Answer this question