Still have questions? Join our Discord server and get real time help.
1

# [SOLVED] Is it possible to apply TextService into Conditional Statements?

Feahren 1581
4 months ago
Edited 4 months ago

I'm currently returning to an attempted project of mine that was to be a Custom Chat. It is extremely old with multiple deprecated methods and logic issues. I believe I've solved kost and am now working on improving reluctance in my lines. I cam across TextService and thought that It would help me out with calculation algorithms. I'm trying to use TextService:GetTextSize() to determine if the String of ChatLabel has exceeded the ChatLabels AbsoluteSize.X. This will, if true, set a new UDim2 Size to act as if the ChatLabel dropped a line. The formula I've implemented into the Peramiters is

local AbsoluteVectors = Vector2.new(ChatLabel.AbsoluteSize.X, ChatLabel.AbsoluteSize.Y)
local StringSize = TextService:GetTextSize(ChattedMessage, 5, "ArialBold", AbsoluteVectors)
--// I'm very confused wih this and haven't texsted it yet, but this is my Conditional Statement.
if (StringSize.X > ChatLabel.AbsoluteSize.X) then
ChatLabel.Size = ChatLabel.Size - UDim2.new(0,0,0,-(-25))
ChatLabel.TextWrapped = true
end


If this cannot be used like so, please let me know, but if there's other uses for it, or functional methods that'll strengthen this Statement, fill me in.

Thanks!

0
iirc GetTextSize returns a Vector2 so line 4 would fail, and why are you doing -(-25) that is the same as 25. incapaxx 3084 — 4mo
0
It was originally a piece in an algorithm, it was to convert x into a positive, how could I fix this TextService issue? Feahren 1581 — 4mo
0
maybe you meant StringSize.X? GoldAngelInDisguise 238 — 4mo
0
Yep, get the X from the resulting Vector2. Rheines 587 — 4mo
0
Thanks so much! Feahren 1581 — 4mo