local function AutoSizeFrame()
local totalWidth = 0
for i,v in ipairs(frame:GetChildren()) do
if v:IsA("TextLabel") or v:IsA("ImageLabel") then
local childAbsolutePosition = v.AbsolutePosition
local childAbsoluteSize = v.AbsoluteSize
local rightX = childAbsolutePosition.X + childAbsoluteSize.X
totalWidth = math.max(totalWidth, rightX)
end
end
frame.Size = UDim2.new(UDim.new(0, totalWidth), frame.Size.Y)
end
I agree with this, if you however want to keep the y value the same as the roblox button you can just keep the y value to an offset then use scale for x value. if you want the child to follow the parent size you should use scale because it will scale based on parent
You sure this isn’t a studio thing? It tends to scuff how people see UI as it’s usually refitted in certain places to make up for the fact that studio itself has loads of menus, when the roblox client itself only has a few buttons.
But what if you have to scale the frame with childrens inside it?
local function resizeFrameToChildren(frame)
local maxWidth = 0
for i, v in ipairs(frame:GetChildren()) do
if v:IsA("GuiBase2d") then
local childAbsoluteSize = v.AbsoluteSize
maxWidth = math.max(maxWidth, childAbsoluteSize.X)
end
end
frame.Size = UDim2.new(UDim.new(0, maxWidth), frame.Size.Y)
end