Resizing UI based on how many lines there are

When I use this script

local changelog = require(game.ReplicatedStorage.Changelog)

local cur = ""
local start = 0

for i,v in pairs(changelog) do
	spawn(function()
		if #v.Numbered == 3 then
			v.Numbered = v.Numbered..".0"
		end
		local temp = script.Parent.Temp:Clone()
		temp.Visible = true
		temp.Ver.Text = v.Ver.." "..v.Numbered
		temp.Desc.Text = v.Desc
		if cur ~= v.Ver then
			local temp2 = script.Parent.NewTemp:Clone()
			temp2.Visible = true
			temp2.Ver.Text = v.Ver
			temp2.LayoutOrder = (start*10)-1
			temp2.Parent = script.Parent.Scrolling
			script.Parent.Scrolling.CanvasSize += UDim2.new(0,0,0,temp2.Size.Y.Offset)
		end
		start = i
		cur = v.Ver
		temp.LayoutOrder = #changelog*10
		temp.Parent = script.Parent.Scrolling
		temp.Desc.Size = UDim2.new(1,0,0,temp.Desc.TextBounds.Y+4)
		temp.Size = UDim2.new(1,0,0,temp.Desc.Size.Y.Offset+temp.Ver.Size.Y.Offset)
		script.Parent.Scrolling.CanvasSize += UDim2.new(0,0,0,temp.Size.Y.Offset)
	end)
end

script.Parent.Scrolling.CanvasSize += UDim2.new(0,0,0,5)

It works in Studio but not TeamTest or Roblox. Is there any reason why and what fixes are there, i’ve tried using task.wait() in multiple parts of the script and still nothing worked.

Why not use ScrollFrames instead?

3 Likes

Use a scrolling frame with the property “AutomaticCanvasSize” property set to Y

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.