If you don’t own the files you can’t change their owner. Clearly you don’t own the files otherwise you wouldn’t need to run this script.
The solution is to run the shell script with elevated privileges (e.g. root) so that you can change the ownership of other user’s files. The standard way of doing this is:
do shell script "blah; blah; blah" with administrator privileges
The ‘with administrator privileges’ will authenticate the user and then use sudo to execute the command as root.