Vex motor code help need

If it is this type of 9V battery
image

it might work but not very long
let's estimate your servo is pulling 200 mA

The capacity of such a 9V-Block is 500 mAh
This means this battery is empty after 2,5 h of operation.

500 mAh / 200 mA = 2,5 h

If you want to run the real thing the servomotor will pull more than 200 mA

There is another problem with these 9V-block batteries
The inner resistance is medium high.
This means if you pull a current of 500 mA from this battery the voltage will significantly drop down through the inner resistance

For measuring all this a digital multimeter is very useful.
You can go on tinkering without a digital multimeter but you will have various situations where - without a digital multimeter you will scratch your head asking "what is wrong?" and then doing a lot of improvised stuff to analyse it

While with using a digital multimeter would make the analysing 2 minutes short

best regards Stefan