What method are you using?
We'd need to see the script steps and calculations before we can spot what should be changed to keep the selected text from being duplicated.
oops screenshot now attached.
The problem lies with the calculation to get the "right part of the string". This calc will return all text to the right of the start of the selected text, thus this text includes the highlighted text and thus your set field step will duplicate the selected text.
Modify this calc so that the Start plus selection size is subtracted from your text length and you should be in business.