How to get the width of a character(a letter)

  1. What do you want to achieve? getting the width of a character

  2. What is the issue? i have no idea how to achieve this

  3. What solutions have you tried so far? none cuz i have no idea how

for example the letter h can be 9 pixels long in a textlabel

local character = -- Path to your character.
local size = character:GetExtentsSize().X -- This is the width of the character in studs. Should be roughly 4 studs.

Is this what you mean?

If you want to get it in pixels then you would have to do some complicated maths to figure it out.

no by character i mean letter like X

Ohhhhhhhhhhhā€¦ Haha I was confused!

For that use this:

local TextService = game:GetService("TextService")

local letter = "h"

local bounds = TextService:GetTextSize(letter, 12, "SourceSans", Vector2.one*1000) -- Letter, Font Size, Font, Maxmimum Size. I setted it to a thousand to remove any limitations.

print("The with of the letter is:", size.X)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.