How do I move a UI only on the Y axis?

I have been stuck on this topic for about an hour now and i have tried 3 different solutions, all of which have failed. I need to move a frame only on the Y axis to lock it in place there because i am making a slider GUI which uses the Scale property.

1 Like

Just change the Y scale/offset components of the UDim2 value., offsetX, scaleY, offsetY), 0, scaleY, offsetY) --change scaleY and offsetY only

1 Like

I’m using the Draggble property (i know it’s deprecated) so it needs to be only Y so the X is fine and can do whatever

1 Like

You could maybe use a run service loop and have like ui.Position =,ui.p.x,0,mouse.y)

1 Like

I’m not sure how the Draggable property works, as I’ve never worked with it, but math.clamp might be of use?

1 Like

You would use the RenderStepped function to always set the position X a fixed value and clamp the Y


local gui = script.Parent.Frame -- for example

local axisToLock = "Y"

local positionToLock = 0.5

local minPos = 50
local maxPos = 400

local runService = game:GetService("RunService")

	-- scale does not seem to work with this. so that's a reason why it's deprecated.
	-- to get the scale you would do this: currentPosition / maxPosition
	if axisToLock == "X" then
		local yPosition = gui.Position.Y
		local yOffset = math.clamp(yPosition.Offset, minPos, maxPos)

		gui.Position =, 0, 0, yOffset)
		local xPosition = gui.Position.X

		local xOffset = math.clamp(xPosition.Offset, minPos, maxPos)

		gui.Position =, xOffset, positionToLock, 0)
1 Like