How do i fix this gui size bug i coded?

This may be bit complicated to explain. When i put the cards at the first time, it doesn’t update to the size of the frame it finds then grabbing it again did update the size.


Another thing is that when i put the blue one then put the yellow noob, the yellow noob card does the same size as the dummy instead of following it’s frame that finds.

Here’s the code:

function UpdateSelection()
	local orderhascard = {}
	for i,v in ipairs(selectionorder) do
		if v.hascard then
			table.insert(orderhascard,v)
		else
			v.instance.Position = UDim2.new(-20,0,0,0)
		end
	end
	for i,v in ipairs(orderhascard) do
		v.instance.Position = MainSelectionPos.Position + UDim2.new((i / 4) - 0.15,0,1,0)
		if not v.isholding then
			TweenService:Create(getValueByIdinMap(clickable,'id',v.id,'instance'),TweenInfo.new(0.5,Enum.EasingStyle.Circular,Enum.EasingDirection.Out),{Position = v.instance.Position}):Play()
		end
		local num = math.sin(limitToOne(i - 1,i,currentSelect) + 0.5707963268)
		local converted = Vector2.new(num * 30,num * 30) / Selection.AbsoluteSize
		v.instance.Size = v.size + UDim2.new(converted.X,0,converted.Y,0)
	end
	for i,e in pairs(clickable) do
		local inst = Selection:WaitForChild(e.id).Size
		local leselectionsize = UDim2.new(inst.X.Scale,0,inst.Y.Scale,0)
		e.startsize[3] = leselectionsize
		for a,v in ipairs(selectionorder) do
			if v.id == e.id and not v.isholding then
				e.startsize[4] = MultiplyUDim2Scale(leselectionsize,{1.2,1.2})
			end
		end
	end
end```