I have a an auto-resizing text label based on the size of the text in the label. But for some reason, the event fires but the size does not change.
local Hints = script.Parent
Hints.ChildAdded:Connect(function(child)
if child:IsA("TextLabel") then
child.Size = UDim2.new(0, math.max(7, child.TextBounds.X) + 23, 0, 30)
print("oooh nice it works but nothing changes!!")
end
end)
local Hints = script.Parent
Hints.ChildAdded:Connect(function(child)
local mathFix = math.max(7, child.TextBounds.X) + 23
if child:IsA("TextLabel") then
child.Size = UDim2.new(0, mathFix, 0, 30)
print("oooh nice it works but nothing changes!!")
end
end)
even tried removing the class checker but no difference.
local Hints = script.Parent
Hints.ChildAdded:Connect(function(child)
if child:IsA("TextLabel") then
local var = math.max(7, child.TextBounds.X)
local newvar = var + 23
child.Size = UDim2.new(0, newvar, 0, 30)
print("oooh nice it works but nothing changes!!")
end
end)
This is a bit overkill but it might not let you do the math.max with additional math behind it.
I know but the thing is, I wanted to optimize the function, so instead of using this: while task.wait(0.1) do I decided to use an event to eat up less resources. And before then, it worked fine.
so honestly i really don’t know. i’ve tried everything i could think of.
well the thing is, I was getting constant random lag spikes which is really bad for UX, since this thing is gonna be made public. And then I don’t want to put a script in each individual text label because that would be less efficient.