Without seeing your code the easiest way to find it yourself is to indent your code (with spacing or tab). When you indent you line up the beginning of a statement and the end of statement of all DO/LOOPs, IF/ENDIF, REPEAT/UNTIL, FOR/NEXT and so on giving you greater visibility for any nesting problems. I personally only use one space but most people hit TAB instead.
set display mode 800,600,32
` Center window
set window position (desktop width()-screen width())/2,(desktop height()-screen height())/2
sync rate 0
sync on
type Trail
X as integer
Y as integer
endtype
dim Tail(20) as Trail
` Setup
set text font "Comic Sans MS"
set text size 35
set text to bold
a$="HELLO WORLD!"
text 0,0,a$
get image 1,0,0,text width(a$),text height(a$),1
hide mouse
` Create a timer
tim=timer()
` Make all sprites to offset
for t=1 to 20
sprite t,0,0,1
offset sprite t,image width(1)/2,image height(1)/2
next t
do
` Clear the screen with black
cls 0
` Check if 20 milliseconds are up
if timer()>tim+20
` Put the current mouse coordinates into the array
Tail(0).X=mousex()
Tail(0).Y=mousey()
` Rotate the array (IanM's command)
rotate array Tail()
` Reset timer
tim=timer()
endif
` Show all the sprites (the tail)
for t=1 to 20
sprite t,Tail(t).X,Tail(t).Y,1
` Change the sprites transparency amount
set sprite alpha t,200-(t*10)
next t
sync
loop