Why is my script editor coming up with connection invalid after running it for a while? This is the script I've found on the web I'm trying to just have the script drop items for me by pressing 1, but it works only for a little while before script comes up with an error "error "System Events got an error: Connection is invalid." number -609"

I use this script

delay 3  
tell application "RuneScape" to activate  
repeat  
    delay 5  
    set mydate to current date  
    repeat while ((current date) - mydate &lt; 1)  
        tell application "System Events" to keystroke (key code 83)  
    end repeat  
end repeat
For a double-click every 5 seconds, until you quit the script, try just

delay 3  
tell application "RuneScape" to activate  
repeat  
    delay 5  
    tell application "System Events"  
        keystroke (key code 83)  
        keystroke (key code 83)  
    end tell  
end repeat