Talk:Anonymous Functions
From Legacy Roblox Wiki
"however this should be avoided in code that runs more than once." I'd never thought of that. So many of my scripts would, say, loop all the zombies in the game and connect events to them anonymously, whereas as you've pointed out there it'd've been much more efficient to point to a single function.
Trappingnoobs (Writer) Have I done something bad? Good? Tell me on my talk page 21:46, 26 December 2011 (UTC)
for _, zombie in ipairs(zombies) do zombie.Torso.Touched:connect(function(by) zombie.Head:remove() --You can still refer to zombie - not possible otherwise end) end
- There's a way around that, though, just take the zombies variable out of the local scopeTrappingnoobs (Writer) Have I done something bad? Good? Tell me on my talk page 22:07, 28 December 2011 (UTC)