UI screengui with scaled frame does not hold its position

I want to overlay a tool with a ui containing a textbox which contains a count which is incremented if the tool object is touched and decremented if it is activated.
I have set the property values in a script as I have found that adjusting the values in the explorer is not remembered when the game is played.
The problem is when the window the game is in is resized the ui does not hold its position when the height is changed. It does ok when the width is adjusted.
pictures are window width changed, height changed, no change.



local frame = script.Parent
local textBox = frame.SafeBoxCount
local framePosScaleX = 0.5
local framePosScaleY = 0.875
local frameSizOffsetX = 60
local frameSizOffsetY = 60
local TXScaleX = 0.3
local TXScaleY = 0.1
frame.Position = UDim2.new(framePosScaleX, 0, framePosScaleY, 0)
frame.Size = UDim2.new(0,frameSizOffsetX, 0, frameSizOffsetY)
textBox.Position = UDim2.new(TXScaleX, 0, TXScaleY, 0)

Anyone any idea how I can get the ui to work for changes of height?

If you put in a UIAspectRatioConstraint it will chnage height and width at the same time

I am sorry but that did not work.
I tried it in the screengui and the frame.
It made no difference.

trying setting the SizeContraint to RelativeYY