:GetTextSize not returning correctly

So, I am using GetTextSize via TextService and it’s returning the text labels TextSize so it will not wrap, which is odd. I am not sure why it’s doing this, I am absolutely stuck right now, so I need some help and yes, it is on the client. I tried setting the frameSize argument to a higher Vector2, but no luck, I tried toggling the label.TextWrapped value, also no luck.

Here’s the code (it’s a module):

Code
local require = require(game:GetService('ReplicatedStorage'):WaitForChild('library').require)
local index = require('utility', 'index')
local service = require('utility', 'service')
local o = {}

--// ui
local ui = script.Parent.Parent
local obj_frame = index.WaitForChild(ui, 'objectives')
local padding_y = 5

function o.new()
	local self = setmetatable({}, {__index = o})
	
	self.objectives = {} --// table containing objectives
	
	spawn(function()
		self:create({
			{text = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'},
		})
	end)
	
	return self
end

function o:create(list)
	if typeof(list) == 'table' then
		self.objectives[#self.objectives + 1] = list do
			for _, a in next, self.objectives do
				for idx, tab in next, a do
					local label = index.WaitForChild(script, 'temp_obj'):Clone() do
						label.Name = #self.objectives
						label.Text = tab.text
						label.Parent = obj_frame
						
						local text_size = service.TextService:GetTextSize(label.Text, label.TextSize, label.Font, obj_frame.AbsoluteSize) do
							print(text_size.Y) --// returns 16; text labels TextSize
							
							label.Size = label.Size + UDim2.new(0, 0, 0, text_size.Y)
							
							service.TweenService:Create(label, TweenInfo.new(.5), {
								TextTransparency = 0,
								TextStrokeTransparency = .9,
							}):Play()
						end
						
						obj_frame.Size = UDim2.new(
							obj_frame.Size.X.Scale, obj_frame.Size.X.Offset, obj_frame.Size.Y.Scale, (idx * (label.AbsoluteSize.Y + padding_y))
						)
					end
				end
			end
		end
	end
end

function o:clear()
	self.objectives = {} do
		for idx, label in next, obj_frame:GetChildren() do
			if label:IsA('GuiLabel') then
				label:Destroy()
			end
		end
	end
end

return o```

Thanks in advance.

Can you print obj_frame.AbsoluteSize? If either its width or height is 0, then GetTextSize will put everything in one line.

2 Likes

yep, that’s the problem, didn’t realize that, thanks