Can anyone explain why and how to resolve?!
That's a fairly simple script, intended as an example rather than a fully functional shooting script.
Documentation for the motion detect function can be found here :
http://chdk.wikia.com/wiki/Motion_DetectionTypically, to solve your problem you want to increase the threshold value (f) and start delay (p). This will respectively change the amount of image change necessary to trigger a shot and add a small delay for the camera to "settle" before looking for motion after each shot.
Try f=40 and p=1000 as a starting point. You will need to edit the script file. It might be better to convert the script to set those as user parameter like this :
@title Motion Detect
@param f = sensitivity
@default f 40
@param p = interval (msec)
@default p 1000
a=6
b=6
c=1
d=300000
e=200
g=1
h=0
i=0
j=0
k=0
l=0
m=0
n=0
o=2
do
md_detect_motion a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p
if( h > 0 ) then
shoot
endif
until (0)
HTH