You need to check if the style is mixed
and do something if it is like using the range functions to get styles of separate characters. TextNode · Figma Developers
let styleId = textNode.fillStyleId
if (styleId === figma.mixed) {
// process each character individually
// or simply get the color of the first character
styleId = textNode.getRangeFillStyleId(0, 1) as string
}
let styleName = figma.getStyleById(styleId).name