Size keeps changing

This is a lore/pop up, for some reason while moving it the size changes
sizechanging.rbxl (60.1 KB)

1 Like

Your text label’s “Scaled” property is causing the problem. If you turn off “text scaled” then it’ll be fine. Use text padding instead of creating 3 empty text labels.

1 Like

Why would I turn off text scaled? The whole frame’s size is changing along with the text

Sorry- looks like I was wrong. Just make a new frame and the bug’s fixed. I can’t tell what property is causing it.

Edit::

Found it. It’s your “Automatic Size” property. Set it to none.

1 Like

Yeah I’ll use padding instead of the empty texts good idea

New frame inside of that frame? Also do I keep text scaled or not?

Keep it scaled- the only issue with it was your “AutomaticSize” property which was sizing it based off your aspect ratio. Apologies about the previous response.

No worries, I can’t seem to fix the issue, could you upload the file by any chance?

It keeps scaling the frame

1 Like

It seems like an issue with the new flex features, specifically VerticalFlex being set to Fill. I would recommend resizing your TextLabels and changing VerticalFlex to None instead, centering other properties as needed.

Edit: It seems like it might be a bugged behavior with AutomaticSize. Setting it to None fixed it for me. It’s kind of a problem with Roblox’s 2D engine - anything scaled doesn’t really function well with other features.

Yes, I see however the whole point is so the new elements get added and expand the frame automatically

image

Desired:

image

Yeah, unfortunately scaled doesn’t work too well with existing features. In your case, it’s kind of a weird math cycle: Scaled property determines size from parent → Parent automatic resize from elements → Repeat.

I’m guessing it’s scaling based off his roblox game’s aspect ratio, which is how I assume it’s being calculated.

Possibly. I personally despise using scaled property, which is why I code my own UI scaling via UIScale, which performs scaling after all the elements’ calculations.

That’s also a fair point. I don’t work with ui’s (rip whoevers going to use my module) which makes me somewhat unqualified to answer this.

Any solution? Been trying to fix this for awhile, not sure what to do

My best solution is what I pointed out above - work with offset and scale via code. I’ll see if I can get a working version using scaled for you right now.

1 Like

Unfortunately I cannot. AutomaticSizing does not work properly with contents that are scaled and resizes itself weirdly due to the mechanic I mentioned above.

Work with offset instead in this scenario and insert a UIScale inside of the ScreenGui. Below is a LocalScript code you can use to automatically scale it for you:

--!strict

local UIScale: UIScale = script.Parent
local CurrentCamera: Camera = workspace.CurrentCamera

-- base resolution to scale from (what you used to make your UI)
local BASE_RESOLUTION: Vector2 = Vector2.new(1920, 1080)
-- determines whether to use the largest or smallest ratio
local USE_LARGEST_RATIO: boolean = true

local function onViewportSizeChanged(): ()
	local xRatio: number = CurrentCamera.ViewportSize.X / BASE_RESOLUTION.X
	local yRatio: number = CurrentCamera.ViewportSize.Y / BASE_RESOLUTION.Y
	
	UIScale.Scale = if USE_LARGEST_RATIO == true then math.max(xRatio, yRatio) else math.min(xRatio, yRatio)
end

CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(onViewportSizeChanged)
onViewportSizeChanged()

There is a caveat where if you are positioning an element, you would have to divide by the UIScale.Scale property:

someElement.Position = UDim2.fromOffset(mousePosition.X / scale, mousePosition.Y / scale)

It also scales from the aspect ratio of the original element, acting as if there is a UIAspectRatioConstraint on the element. Unfortunately there is no way around this using this method at the moment.

Thank you, could you by any chance link this up in the place I provided? I tried importing and switch the positions on offset but it still does it, maybe because I’m still using AutomaticSize on XY?

CustomScalingAndPositioning.rbxl (60.3 KB)
Using the same code as above and the code below to position, accounting for scaling and topbar inset:

--!strict

local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")

local Frame = script.Parent
local UIScale = Frame.Parent.UIScale
local CurrentCamera: Camera = workspace.CurrentCamera

local function update(): ()
	local mouseLocation: Vector2 = UserInputService:GetMouseLocation()
	local topbarInset: Rect = GuiService.TopbarInset
	local toXLocation: number = mouseLocation.X / UIScale.Scale
	local toYLocation: number = (mouseLocation.Y - topbarInset.Height) / UIScale.Scale
	
	Frame.Position = UDim2.fromOffset(toXLocation, toYLocation)
end

GuiService:GetPropertyChangedSignal("TopbarInset"):Connect(update)

CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(update)

UserInputService.InputChanged:Connect(function(inputObject: InputObject): ()
	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		update()
	end
end)

update()
1 Like

Thank you, this sorts out the sorting problem but I was looking for the frame’s X and Y be based off of the largest text so it could represent a lore type of system

Like this for example
image

Yes, you can do that with offsets! Instead of using a set size for your TextLabels, set the Size back to {0, 0}, {0, 0} and AutomaticSize to XY. You may also need to turn off TextScaled to false and manually set the size since text size also automatically changes with UIScale.