I tested your code, and it seem to work for me. But there are one difference. I stored all the object numbers in an array, and then moved along it in the FOR-NEXT loop that controls the player movement. Here is my code:
text 10,10,"Loading..." : wait 1
sync on : sync rate 60 : autocam off : hide mouse
rem Make the matrix
make matrix 1,24000,24000,50,50
rem Make the player
make object sphere 1,50
rem Make the mouse
make object sphere 2,30
rem Color the player
color object 2,rgb(255,100,255)
rem Position the player
position object 1,12000,0,12000
rem The position of the mouse
posx=12000
posz=12000
rem The other variables
MouseState=0
PlayerSelect=0
rem The array
dim objects(1000) as integer
getFreeObject()
rem As for the other objects...
for n=1 to 1000
repeat
color object objects(n),rgb(100,255,100)
position object objects(n),rnd(24000),0,rnd(24000)
until object collision(objects(n),0)=0
next n
rem The camera
position camera 12000,3000,12000
xrotate camera 90
set camera range 300,7500
rem All 2d is red!
ink rgb(255,100,100),0
rem The main loop
do
rem Camera movement
if rightkey()=1 then position camera camera position x()+20,3000,camera position z()
if leftkey()=1 then position camera camera position x()-20,3000,camera position z()
if upkey()=1 then position camera camera position x(),3000,camera position z()+20
if downkey()=1 then position camera camera position x(),3000,camera position z()-20
rem How to control the camera's position
if mouseclick()=2 then position camera object position x(3),3000,object position z(3)
if spacekey()=1
posx=object position x(1)
posy=object position z(1)
position camera object position x(1),3000,object position z(1)
endif
rem Position the mouse
inc posx,mousemovex()/2
inc posz,mousemovey()/-2
position object 2,posx,0,posz
rem Collision
for x=1 to 1000 step 1
if object exist(objects(x))
if object collision(2,objects(x))
circle object screen x(2),object screen y(2),3
rem Click to select
if mouseclick()=1
MouseState=1
PlayerSelect=objects(x)
endif
exit
endif
endif
next X
rem The player moves to the object
if PlayerSelect<>0
point object 1,object position x(PlayerSelect),0,object position z(PlayerSelect)
move object 1,40
if object collision(1,PlayerSelect)=1 then PlayerSelect=0
endif
rem Update screen
sync
loop
end
rem Find a free object and create it
function getFreeObject()
for n=1 to 1000
repeat
inc v,1
until object exist(v)=0
objects(n)=v
make object cube objects(n),50
next
endfunction
. Hope it will help you.
EDIT:
Forgot to mention how to control everything. You control the camera whith the arrowkeys, and the "mouse" with the mouse. You press the right mousebutton to go to the "mouse", and space to position both the camera and the "mouse" at the player. If you can select one of the boxes, a red circle will apear around the "mouse", and then you select that box by clicking at the left mousebutton.