I'm very new to applescript, first day of trying to do anything.

What I am trying to do is, when a game starts up I want it to run a script that will change my function keys to standard function keys. I have a script for it,
------------------------------------------------
tell application "System Events"
if not UI elements enabled then
set UI elements enabled to true
end if
end tell

--Enable/Disable "Use all F1, F2, etc. keys as standard function keys" option in Keyboard & Mouse Preference pane and close System Preferences
tell application "System Events"
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard & Mouse" of application process "System Preferences"
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if

------------------------------------------------
but I can't figure out how to get it to run when the application starts. Is this even possible? I would appreciate any help.