Hi guys can anyone of you guys explain to me what the pairs and ipairs does in a simple way
I need an example
Thanks for taking your time while reading this
Hi guys can anyone of you guys explain to me what the pairs and ipairs does in a simple way
I need an example
Thanks for taking your time while reading this
so what it does is it loops through a thing.
Sounds complicated? i’ll dm you, ill teach you about it.
It kinda does sound complicated but I did hear its useful
its VERY VERY useful, sounded complicated to me too until i found out how it works, its not really that complicated, its more of a beginner thing
oh ok, I’ll try to understand it with all my might.
pairs() is kinda unpredicatble, but ipairs() not.
Source: Something i remembered from a long time ago.
You dont need to know the difference, nowadays you dont really need them
so one of the use scenarios can be to find out how many parts are in the workspace.
so you mean ipairs() aren’t that useful anymore?
no, you dont need them anymore, but they cause no harm when using
I think I do understand what you mean but ok
why dont you look it up? Why does this post exist?
I did last night but I didn’t understand any of them
for i,v in ipairs(workspace:GetDescendants) do print(v.Name)
i
is the index,
v
is the instance.
For everything it will find, it will print out its name
What do you not understand?
It just loops through a dictionary or table, then it gives you an index and a value
I understand some part of the script but I don’t know how to use v though
ill explain it to you in the DM’s
its not super easy to explain (atleast for me)
for i,v in ipairs(workspace:GetDescendants()) do
print(v.Name) -- prints the name of the instance
print(i) -- prints the number in order of the instances inside (1,2,3,4,etc)
end
-- v is the instance (Part,Model,etc)
Ok
I’ll dm you when I can but not now