This should work better for you 
SCAR Code:
program New;
{.include srl/srl.scar}
function FindTreeMS:boolean;
var
x, y, i, s: integer;
MapleColor : Array [0..3] of Integer;
Maple: TPointArray;
ATPA: T2DPointArray;
MXY: TPoint;
begin
if not LoggedIn then exit;
FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 15);
if length(Maple) = 0 then
begin
FindColorsTolerance(Maple, 17274, MSX1, MSY1, MSX2, MSY2, 4);
end;
if Length(Maple) = 0 then Exit;
ATPA := SplitTPA(Maple,5);
SortATPASize(ATPA,True);
for i:= 0 to High(ATPA) do
begin
MXY:= MiddleTPA(ATPA[i]);
MMouse(MXY.X, MXY.Y, 3, 3);
wait(100);
if (pos('aple',rs_GetUpText) <> 0) then
begin
repeat
GetMousePos(x, y);
Result:= true;
FindEnt(x, y, true);
Mouse(x, y, 0, 0, true);
wait(5000);
AntiRandoms;
until(InvFull);
end;
end;
if not Result then
begin
MapleColor[0]:=27796;
MapleColor[1]:=12911;
MapleColor[2]:=27797;
MapleColor[3]:=17015;
for s:= 0 to 3 do
if FindObjCustom(x, y, ['aple'], [MapleColor[s]], 4) then
begin
if IsUpText('aple') then
begin
repeat
GetMousePos(x, y);
FindEnt(x, y, true);
Mouse(x, y, 0, 0, true);
wait(5000);
AntiRandoms;
until(InvFull);
end;
end;
end;
end;
begin
end.