How to compare between two scrolling frame

Hi i have some problem , im tryna make cashier system . So to get money , cashier must match with menu customer wanted . When npc come to cashier, it will random pick image button from menu list and parent to customer’s scrolling frame and cashier must pick menu from menu list . Once clicked , it will clone image button and parent to cashier’s scrolling frame . So when cashier clicked the confirm button it will compare between scrolling frame cashier and customer . Btw the image button got their own specific name . Question is how to compare ? If match then it will print yes and fire event . Let me know :saluting_face:

1 Like

Since the image buttons have got their own specific names, you can use for loops to compare them, like this:

function compare()
	for _, button in pairs(cashierFrame:GetChildren()) do
		local buttonMatched = false -- If this is true then the button is matched with customer's one
		
		for _, anotherButton in pairs(customerFrame:GetChildren()) do
			if button.Name == anotherButton.Name then
				buttonMatched = true -- The buttons matched with each other
				break
			end
		end
		
		if not buttonMatched then
			return false -- The two scrolling frames aren't matching
		end
	end
	
	return true -- The two scrolling frames are matching
end

print(compare()) -- Prints true if the two scrolling frames match with each other,
                 -- or false if they don't.

Also, this isn’t the right category, you would want to go to #help-and-feedback:scripting-support. :happy1:

1 Like

Thanks i really need it ! Ah my bad yikes ! , Wait what if the list has 4 image button will it work?

1 Like

This is not supposed to be in Dev Discussion…

Just to keep the forum organized, move this to scripting support.

1 Like

Alright i did :saluting_face: … dear 30 min char

1 Like

Yes, it will work no matter how many image buttons there are.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.