Boolean don't changing

boolean = false
script.Parent.MouseButton1Click:Connect(function()
	for _, i in pairs(script.Parent.Parent:GetChildren()) do
		local button = i:IsA("TextButton")
		local textbox = i:IsA("TextBox")

		if button or textbox then
			if boolean == false then
				boolean = true
				script.Parent:TweenPosition(script.Parent.Position - UDim2.new(-1.4, 0, 0, 0))
				
			else
				script.Parent:TweenPosition(script.Parent.Position - UDim2.new(1.4, 0, 0, 0))
				boolean = false
			end
		end
	end
end)

while wait(.2) do
	print(boolean)
end

who can help pls?

If there is a even number of children script.Parent.Parent:GetChildren() then your boolean will switch on and off and settle where it started. I am not sure why you have a for loop inside the connected function like that, maybe boolean should be for each textbox/textbutton?

idk, how i can explain but idk.

local boolean = false
script.Parent.MouseButton1Click:Connect(function()
	for _, i in pairs(script.Parent.Parent:GetChildren()) do
		local button = i:IsA("TextButton")
		local textbox = i:IsA("TextBox")

		if button or textbox then
			if boolean == false then
				script.Parent:TweenPosition(script.Parent.Position - UDim2.new(-1.4, 0, 0, 0))
			else
				script.Parent:TweenPosition(script.Parent.Position - UDim2.new(1.4, 0, 0, 0))
			end
		end
	end

    boolean = not boolean
end)

Try this, it will flip the boolean at the end of the for loop instead of for every iteration.