Let's deconstruct your code for a minute.
"If alive=0" - I'll assume this means that if the enemy is not alive. Moving on.
"For i = 100 to 0" This starts the For - Next loop, at 100, and wants it to go down to 0. I've tested it, and I'm pretty sure you can only go up (for i = 0 to 100)
"Fade Object Enemy,i" This tells the system to fade the object to the ambient light level of the engine. This may not be what you want, first of all.
I recommend the "Set Alpha Mapping On" command, as this actually fades it to become invisible. You also need to add a Sync command in the loop to update the screen while it's fading.
To do the 'for i = 100 to 0', you have to use a handy command called 'abs(value)'. It returns the positive form of a negative integer. Use this to 'count down'.
Better yet, compile and run the below program.
It should show you an example of fading.
Press the spacekey to fade.
Have fun!
`///Basic Stuff, initiate the 3d enviroment
sync on : sync rate 60
`///declares enemy, and makes a cube, makes sure it's alive, and colors it
enemy = 20
make object cube enemy, 10
color object enemy, rgb(255,0,0)
alive = 1
do
`///Your modified code - notice the For loop starts at -100
`///when it's converted to an integer, it's the equivalent of counting down
`///from 100 to 0
If alive=0
For i = -100 to 0
Set Alpha Mapping On enemy,abs(i)
sync
next i
`///this line is optional. I just did this so that you could
`///'re-fade' things an experiment
Alive = 1
endif
if spacekey() = 1 then alive = 0
IF Alive = 1 then Set Alpha Mapping On Enemy,100
sync
loop
end
EDIT: Wow, all that time I spent making that code and Virtual Nomad beat me to it
And if you want a small delay, use Virtual Nomad's code. Or just stuff in a small wait (like 50 or so) in my loop.
Programming? Not my Forte. But THAT is!
-insert picture of a KIA Forte here-