Ok, now I understand

Maybe you should change to a different loop or even remove the for - next loop. Like this
SYNC ON:SYNC RATE 30
set display mode 800,600,32
global npc as integer = 1
do
makeobject()
sync
loop
end
Function makeObject()
make object cube npc, 0.2
position object npc, rnd(20), rnd(30), rnd(20)
inc npc, 1
text 0, 0, str$(npc)
EndFunction I
Or if you know how many cubes you want, lets say 200, you could use an array
SYNC ON:SYNC RATE 30
set display mode 800,600,32
global npc as integer = 1
global dim objects(200) as integer
for n = 1 to 200
objects(n) = n
next n
do
makeobject()
sync
loop
end
Function makeObject()
for n = 1 to 200
if object exist(n) = 0
make object cube objects(n), 0.2
position object objects(n), rnd(20), rnd(30), rnd(20)
endif
next n
text 0, 0, str$(n)
EndFunction I
Hope this answers your question
A clever person solves a problem, a wise person avoids it - Albert Einstein