When you update .Text
property the CursorPosition
property is calculated incorrectly if its position is not at the end of the input.
You need update text each input with the same content:
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
script.Parent.Text = script.Parent.Text
end)
For example, similar code is used in reactive components of Roact
When entering a character not at the end of the string, then CursorPosition
increases by 2 units instead of 1
Video of the behavior:
Repro place
CursorPosition Bug.rbxl (62.0 KB)