You do not want to use “it” here, you want to use “result”. As you can see “it” is the Finder. “Result” gives you the results from the previous command. Also the “selection” will be a list of files, even if only one file is selected in the finder. To access the items in a list you use “item 1”, “item 2” etc. You don’t even need “activate” here. Activate brings the Finder to the front which isn’t necessary to get the selection.
tell application "Finder"
get the selection
set selectedFile to item 1 of result
end tell