#Pairs

1 messages · Page 1 of 1 (latest)

tribal vessel
#

Can someone please explain to me how this code works?
for _, button in pairs(buttons:GetChildren()) do
button.Touched:Connect(function(otherpart)
local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
local touched = button:FindFirstChild("Touched") -- arguments of button
if humanoid and touched and touched.Value == false then
ab(button, touched)
end
end)
end

arctic viper
#

for _, button in pairs(buttons:GetChildren()) gets every item inside of a folder/model

the first value (_) is the index, which counts how many objects have been counted
the second value (button) is the current object, and is what is referenced when the button variable is used

#
for i,v in pairs(folder:GetChildren()) do
  print(v.Name)
end

would print the name of every object in a folder

#

the output would look like:

Part1
Part2
Part3
Part4

(if all of the names are ordered like that)

#

the first and second variables can be renamed like normal variables

tribal vessel
arctic viper
#

its just the name used for "v"

echo stoneBOT
#

studio** You are now Level 7! **studio

vague thistle
forest moss
#

k,v is my goat