You shouldn't need a script. If the lookup isn't working, something is either not set up right in your relationship to your look up field, the auto-enter field options or in how you enter/select the data that looks up this amount.
The Invoices starter solution uses the Products table as a source of unit prices for records in the Invoice Data table. You might compare your set up to how it is done in this starter solution to try and figure out why it is not working.
You can also take a look at this thread on the subject: Auto Fill
And if that doesn't work, you can try describing what you tried to set up so that others can help you figure out why it didn't work for you so that you can get it to work.