You only need to declare the variable once. This is how I would do it inside the function. Your
script might need more work afterwards...
Main()
Func Main()
Local $data1, $data2, $pants = 1
While 1
$data1 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
If IsArray($data1) Then
Send("{ALTDOWN}")
Sleep(60)
Send("{0 down}")
Sleep(60)
Send("{0 up}")
Sleep(60)
Send("{ALTUP}")
Sleep(50)
MouseClick("primary", $data1[0] + 5, $data1[1] + 5, 1, 0)
Sleep(900)
$pants = 0
Else
$data2 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
If IsArray($data2) Then
MouseClick("primary", $data2[0] + 5, $data2[1] + 5, 1, 0)
Sleep(500)
Else
If $pants = 0 Then
Send("{ALTDOWN}")
Sleep(60)
Send("{9 down}")
Sleep(60)
Send("{9 up}")
Sleep(60)
Send("{ALTUP}")
Sleep(50)
$pants = 1
Else
$pants = 1
Sleep(100)
EndIf
EndIf
EndIf
WEnd
EndFunc