How To Compare Names And Find Matches

Hi all, I’d like to know how to compare names of children from a folder and a GUI. Here is my code so far:

-- Compare images names to values names
game.Players.PlayerAdded:Connect(function(player)
	local Gui = player.PlayerGui
	local images = Gui:WaitForChild("FoundClothing").Clothingframe:FindFirstChild("Scroll"):GetChildren()
	local valuelist = player:FindFirstChild("PlayerData"):FindFirstChild("SaveImage"):GetChildren()
	
	
end)

How would I achieve this?
Thanks!

2 Likes

Use a for loop and check if the image name is the same as the value’s name
if image.Name == value.Name then

1 Like

Try this
for i,v in pairs(–The thing here:GetChildren())do
if v.Name == --Something here.Name then
–Do stuff here.
end
end

1 Like

I might not sure if this works but it’s what I am trying to explain in my previous post.

for i=1,#images do
	for x=1,#valuelist do
		local image = images[i]
		local value = valuelist[x]
		if image.Name == value.Name then
			-- Code
		end
	end
end
2 Likes

Hmm, it doesn’t print anything. Any idea why?

game.Players.PlayerAdded:Connect(function(player)
	local Gui = player.PlayerGui
	local images = Gui:WaitForChild("FoundClothing").Clothingframe:FindFirstChild("Scroll"):GetChildren()
	local valuelist = player:FindFirstChild("PlayerData"):FindFirstChild("SaveImage"):GetChildren()
	for i=1,#images do
		for x=1,#valuelist do
			local image = images[i]
			local value = valuelist[i]
			if image.Name == value.Name then
				print("It works! Yay")
			end
		end
	end
	
end)

See the issue I think

local value = valuelist[x]
1 Like