It doesn't work because the function ends when you 'Wait'. It executes like this:
1. 'On function' triggers
2. First action retrieves correct parameter
3. Wait action is used
4. The function ends and execution returns to the rest of the event sheet
5. Event sheet keeps ticking for a while during the 'Wait', until the time expires
6. The last action tries to retrieve a function parameter, but it's not in a function any more, so returns the default 0.