CursorPosition determines the offset of the text cursor in bytes, or -1 if the TextBox is not currently being edited. A value of 1 represents the beginning, the position before the first byte in the
TextBox/Text|Text property. When used in conjunction with the
TextBox/SelectionStart|SelectionStart property, it is possible to both get and set selected text within a TextBox.
It should be noted that the units of this property is bytes and that many unicode characters such as emoji are longer than 1 byte. For instance, if a player types into the TextBox “Hello👋” – “Hello” immediately followed by the waving hand sign – the cursor position would be 10, not 7, since the emoji uses 4 bytes.
This code sample demonstrates reading the current selection of a