for i,v in pairs(Hello:GetChildren())
if then -- I want to do a if check for whether or not the value is in the index here
end
end
1 = Cat, 2 = Dog, 3 = Bat
but if i were switch the dog and the cat value then i would need a check to see if the index matches the value. is there anyway to go on doing this
Well, then you wouldn’t actually need to do that… Any programming language you could find that’s decent already does that, that’s how for loops work. But, if it matters that much, then you could just do this:
for i,v in pairs(Hello:GetChildren())
if Hello[i] == v then
end
end
local Reference = {
[1] = "Cat",
[2] = "Dog",
[3] = "Bat",
}
local randomArray = {"Dog", "Cat", "Bat"}
for idx ,name in randomArray do
if Reference[idx] == name then
print(name, "is in the correct index")
end
end