Help with Looking for names

I am trying to make it so that if the player has a specific value in a numberval (0) in their plrreasearchfolder it looks for viewportframes in a two different frames named the numberval so it can make a icon invisible if the value is THE specific one.

To the point of finding the names and values inside the player’s folder it works.
the second “Loop” doesn’t work.

local player = game.players.localplayer -- for example
local plrresearch = player.Research
local groups = script.Parent.Frame:FindFirstChild("Naval" and "Ground")
	for _, v in pairs(plrresearch:GetChildren()) do	
		if v.Value == 0 then local names = v.Name  -- works to this point
		wait(0.1)
			for _, e in pairs(groups:FindFirstAncestor(names)) do -- I tried many things here like "findfirstchild" or "FindfirstDescendant" 
				if e:IsA("ViewportFrame") then -- error on the loop "invalid argument #1 to 'ipairs' (table expected, got nil)"
					local locked = names:FindFirstChild("Locked")
					locked.Visible = false
				end
				
					
				end
			end
end

Did some testing, this only returns Ground
Change it to 2 separate variables, combine this with what @SeargentAUS said.

this should be

for _, e in pairs(groups:GetDescendants(names)) do

In regards to what @domboss37 said, if you want to have the 2 things as one variable,consider making it a table:

local groups = {script.Parent.Frame:FindFirstChild("Naval"), script.Parent.Frame:FindFirstChild("Ground")}

Another thing: instead of for _, v in pairs(), it should be for _, v in ipairs()


gimme a moment, ima quickly rewrite your script

1 Like

Ok, your script has way more issues than I thought, and without seeing the hierachy of all the components (a screenshot of explorer), I cant really do much more:

local player = game.players.localplayer -- for example
local plrresearch = player.Research
local groups = {script.Parent.Frame:FindFirstChild("Naval"), script.Parent.Frame:FindFirstChild("Ground")}
for _, v in pairs(plrresearch:GetChildren()) do	
	if v.Value == 0 then
		local names = v.Name  -- works to this point
		wait(0.1)
		for _, i in ipairs(groups) do
			for _, e in pairs(i:GetDescendants()) do 
				if e:IsA("ViewportFrame") and e.Name == names then 
					local locked = e:FindFirstChild("Locked")
					locked.Visible = false
				end
			end
		end
		
	end
end

Note: You may need to modify the locked thing - I don’t got sufficient context about it to make sure it works

Thanks for the Help Guys.
@SeargentAUS @domboss37