Basically, say I have a frame that’s the shape of a square with a textlabel inside of it
How can I stretch it on the X axis to match the length of the text
PS: I do know about TextLabel.TextBounds, but I have no idea how to “add” that to the size of the frame
Just make the frame the parent of text, maybe then it streches.
That seems like extremely bad practice
Ok wait, if you need script, I’ll try myself and tell you in a moment
use AutomaticSize
and set it to X
its on properties
He needs to detect if the size is changed and if it is, then scale the textlabel
Try this - (Maybe I’m wrong because I’m directly writing)
local player = game.Players.LocalPlayer
local frame = player.PlayerGui.ScreenGui:WaitForChild(whatever the frame is)
frame:GetPropertySignalChanged("Size"):Connect(function()
--Change the text label bounds
end)
No no the string doesn’t change after creation (via script)
It’s just there are multiple possibilities for the text
Lemme rephrase the question so yall stop throwing workarounds:
How do I make a frame longer or shorter based on the textbounds of a textlabel
Try this now
local player = game.Players.LocalPlayer
local frame = player.PlayerGui.ScreenGui:WaitForChild(whatever the frame is)
local textlabel = player.PlayerGui.ScreenGui:WaitForChild(whatever the textlabel is)
textlabel:GetPropertySignalChanged("TextBounds"):Connect(function()
--Change the frame's size
end)
Edit:You said the text can’t change after creation, then how can it change it’s TextBounds and why should it ? I don’t really understood
Holy god I swear
I have a textlabel with text which DOES NOT change, however it isn’t always the same string as it pulls it randomly from a table
Also I ALREADY HAVE THE TEXTBOUNDS all I need is to know HOW DO I APPLY IT TO THE ACTUAL FRAME
Wait, are you asking that how can you make the size of the frame based on textbounds ?
dude
frame.Size = UDim2.new(0, TextLabel.TextBounds.X, frame.Size.Y.Scale, frame.Size.Y.Offset)
YES
I need to change the frame’s size on the X axis depending on the TextBounds of a TextLabel
Hmmm…So it must be easy I guess
Just change the frame size on the X to the textbounds on X
Try this now
local player = game.Players.LocalPlayer
local frame = player.PlayerGui.ScreenGui:WaitForChild(whatever the frame is)
local textlabel = player.PlayerGui.ScreenGui:WaitForChild(whatever the textlabel is)
textlabel:GetPropertySignalChanged("TextBounds"):Connect(function()
--Change the frame's size
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.