Source replacing via plugin - cursor problem!

Hi! I’m making a private plugin to replace specific keywords in my scripts using gsub. How would I make the cursor go to the end of the line instead of this?? It’s quite annoying but it’s fine if there’s not a solution. Any help is appreciated!

Where the cursor goes after the replacement
Where I want it to go

Replacement Code
current_connection = active:GetPropertyChangedSignal("Source"):Connect(function()
	for i, v in pairs(replace) do
		active.Source = tostring(active.Source):gsub(i,v)


I don’t really know much about plugins, but it is not necessary to integrate a motion or something that sends the cursor to the end of the line, normally your keyboard will have a key called “End” that will always send the cursor to the end of the paragraph or page.

Oh, I actually didn’t know that, it could actually be useful in some cases, thanks! Also, I ended up finding a different and newer method of changing the script source using the ScriptEditorService, and it fixed the issue.