Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

TextService:GetTextSize() but a vertical version?

Asked by 4 years ago

I thought :GetTextSize was made for vertical uses, but its for horizontal uses. I want to get the vertical version of :GetTextSize() for my custom chat system. Like how Robloxs Chat does it, it sizes itself automatically enough for the text to fit with no extra space. I tried switching sides with X and Y but it doesn't work for me.

I need help with this, heres my script:

game.ReplicatedStorage.SendMessageRequest.OnClientEvent:Connect(function(plays, argument)
    local playerName = plays.Name
    local textMessage = argument

    local clone = script.Parent.Template.TextPlayerMessageBox:Clone()

    local message = playerName .. ": " .. textMessage

    clone.Content.Text = message

    local sizeSetRaw = textService:GetTextSize(message, clone.Content.TextSize, clone.Content.Font, clone.Content.AbsoluteSize)

    print(sizeSetRaw)

    local sizeSet = UDim2.new(0, clone.Content.Size.X.Offset, 0, sizeSetRaw.X)

Please help

thx

1 answer

Log in to vote
1
Answered by 4 years ago

Discussed in Discord, question is resolved.

Issue came down to the fact clone.Content.AbsoluteSize was limiting the size of the wrapped text to expand. Was changed to Vector2.new(maxWidth, math.huge) to support infinite scaling in height. (maxWidth being a constant variable of 459 for his total chatbox width)

Ad

Answer this question