of     1   

Smittxn
#138111838Wednesday, June 25, 2014 7:50 AM GMT

I am nooby scripter before you begin. What is the function of: for _, v in pairs do --code end And what is ipairs, how do you use it, when should you use it, what's the difference between pairs and ipairs. I do know that the for _, v in pairs can be used to do this: function cleanUpcleanUpeverybodyCleanUp() for _, v in pairs (game.Workspace:GetChildren()) do if v.ClassName == "Hat" then v:Destroy() end game.Workspace.ChildAdded:connect(cleanUpcleanUpeverybodyCleanUp) But what is the '_' for and how is it used? I've also seen this: _G.name <-- What?
lampwnage121
#138112253Wednesday, June 25, 2014 8:00 AM GMT

_G is a global table that can be used to communicate between scripts. http://wiki.roblox.com/index.php?title=Function_Dump/Core_Functions#G ipairs stops at the first nil value in the table pairs keeps going. http://wiki.roblox.com/index.php?title=Ipairs#ipairs http://wiki.roblox.com/index.php?title=Ipairs#pairs
Smittxn
#138112358Wednesday, June 25, 2014 8:03 AM GMT

Thank you very much. For some reason, I wasn't able to locate these on the wiki.
lampwnage121
#138112481Wednesday, June 25, 2014 8:06 AM GMT

pairs keeps going and ignores nil values*
RoflBread
#138113554Wednesday, June 25, 2014 8:31 AM GMT

_ is a variable like any other. It's just common to see it used in for loops. ipairs goes over integer indexes only.

    of     1