For i,v in pairs() onlying applying to one item even though it should apply to three

If a button is pressed, the button turns active. The local script always loop if the all TextButton inactive or active. If the button isn’t active, it will change to arrow_down, and if the button is active, it will change to arrow up. However, the script always loop on one item instead of the other two. (three in total)

local arrow_up = "insertassestid"
local arrow_down = "insertassetid"

local handToUI = script.Parent

local core_frame = handToUI:FindFirstChild("coreFrame")

for i,v in pairs(core_frame:GetChildren()) do
	if v:IsA("TextButton") then
		while task.wait(1.5) do
			print(i, v.Name) -- only prints 6  selectItem3
			if v.Name ~= "handToUser" and v.Active == true then
				print(i, v.Name)
				v:FindFirstChild("ImageLabel").Image = arrow_up 
			else
				print(i, v.Name)
				v:FindFirstChild("ImageLabel").Image = arrow_down 
			end
		end	
	end
end

Your while loop never ends so what your for loop outside of it says to do is irrelevant.

1 Like

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