Automatic Canvas Size (Scrolling Frame)

Why when I clone in the studio it works the Automatic Canvas Size but when I test it in game, it doesn’t work?

EDIT: It works if from the first time it’s visible (Children inside Scrolling Frame), but if I make it visible = false and in game i make it Visible = true, it doesn’t update the size. How to fix?

Could we see your script? Are you sure it didn’t ‘deactivate’ or so while it was invisible due to an action from another script or so?

Well I already fix it, with

local frame = script.Parent

local layout = frame:FindFirstChildWhichIsA("UIGridStyleLayout")

local absoluteContentSize = layout.AbsoluteContentSize

frame.CanvasSize = UDim2.new(0, 0, 0, absoluteContentSize.Y)

layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()

	local absoluteContentSize = layout.AbsoluteContentSize

	frame.CanvasSize = UDim2.new(0, 0, 0, absoluteContentSize.Y)

end)

Well but the my UI is for like if there is no player in the team, make it visible = false, but if player want to see hidden (visible = false) team, they can.

2 Likes

If that script works for you, mark your own reply as “solution” so others with similar problems can find it easier!

you don’t need a script for this, just enable AutomaticCanvasSize on properties

Well yes, but when i make the child visible or not in-game, it doesn’t update.

Likely due to some position/sizing conflicts (multiple layout instances attempting to override the positions and or sizes of affected GuiObjects).