[HELP!] TextBounds Not Returning Correct Values

  1. What do you want to achieve? I am trying to make my own version of TextScaled by looping through all the text sizes from 100 - 1 and finding the highest one that fits inside of the text box.

  2. What is the issue? TextBounds isn’t returning correct values

  3. What solutions have you tried so far? I looked on the Dev Hub/Dev Forum but got nothing.

Here is the LocalScript:

object.TextSize = 1
currentSize = 101
TextBoxSize = object.AbsoluteSize
repeat
	currentSize = currentSize - 1
	object.TextSize = currentSize
	wait(.1)
	TextSize = object.TextBounds
	print(TextBoxSize, TextSize, object.TextSize)
	if TextBoxSize.X < TextSize.X and TextBoxSize.Y < TextSize.Y then
		TextSizes[#TextSizes + 1] = currentSize
		currentSize = "DONE"
		print("!!!FINISHED")
	end
	if currentSize ~= "DONE" then
		if currentSize < 1 then
			warn("A FATAL ERROR OCCURED! " .. tostring(currentSize))
			return
		end
	end
until currentSize == "DONE"

At one of the lines, I put this:

TextSize = object.TextBounds
print(TextBoxSize, TextSize)

For some reason, TextSize (the variable that holds the TextBounds) never changes, even though I change the size of the text.
BTW, object is a TextLabel.

Is there any particular reason you need to custom scale text like this? It seems that TextScaled seems to be the better option.

The size of the Gui will not change when you change the text size, so unfortunately this method will not work.

  1. I am making a custom TextScaled because of an issue with TextScaled
  2. Isn’t TextBound the size of the text, not the GUI element? Or should I switch to TextService:GetTextSize?

Ah I misread your script, TestBounds will work. However you should define TextSize as a local variable, rather than a global one.

Could you please share your entire script? It seems like a fair number of variables have been left out.

Can I private message it to you and we continue this thread through private messages pls? I don’t want to release this code to the public until it’s all done.

Edit: I won’t be able to get it to you until tomorrow sorry!

PMs are fine, feel free to contact me.