Password problem

New to applescript, but have written this one that works to an extent BUTTT… can’t get it click on the lock to make changes and enter my password automatically. I know it can be done I saw it some where on the web Friday i remember the password was wrapped… or something, Anyway:

tell application “System Preferences”
activate
end tell
tell application “System Events”
tell process “System Preferences”
click menu item “Network” of menu “View” of menu bar 1
tell window “Network”
if (exists pop up button 1) then
tell pop up button 1
click
tell application “System Events” to keystroke (ASCII character 30) → up arrow
end tell
tell application “System Events” to keystroke (ASCII character 30) → up arrow
tell application “System Events” to keystroke return
end if
end tell
end tell
end tell

This opens system preferences changes location and show to my setting the would change tcp/ip if I could unlock with privledges. any help is appreciated in advance.

finally got the lock to open, still cannot get the password in automatically.