Your current script does:
Find the color
Get the current mouse coordinates into x,y
Click x,y which are your current mouse coordinates
The mouse never moved. Don't reset x,y as they contain your target coordinates. Also, use SRL's Mouse and MMouse. Most other mouse procedures are (relatively more) detectable.
So, to reiterate, you should do
reset x,y to starting point
FindColor into x,y your color
MMouse to x,y
check IsUpText
Mouse x,y click
EDIT:
Or, as SCAR-script
SCAR Code:
program FindColor
{.include SRL/SRL.scar}
const
TheOreColor = 12345;
function ClickOre: Boolean;
begin
if (FindMainColor(x,y,TheOreColor,5,True)) then
begin
MMouse(x,y,5,5);
if (IsUpText('Mine')) then
begin
Mouse(x,y,5,5);
Flag;
Wait(100+random(200));
result := true;
end
end
end;
I deviated from your ideas a bit to demonstrate some things.
Use SRL, it simplifies stuff by placing wrappers around code you no longer need to write.
Use if-reasoning. Make sure what you think is true actually is.
Use a function that returns True after completing, and recall it if it's False.
I recommend you look up Mouse (click), MMouse (move cursor), and Flag (wait for the red minimap flag while walking to go away), IsUpText:Boolean (what's the mouse-over message?).