Alright, so I'm making a custom scrolling frame because ROBLOX's won't work correctly for what I'm trying to do. So right now I'm just trying to get the scroll draggers to move up and down or side to side depending the axis I set without it going passed the boundaries.

The problem is that the dagger won't go passed the top boundary, but it will go passed the bottom one.

Here is an example: Scrolling Problem

Help??

local getAxis = function(Axis, frame)
	local axis = (frame.Slider.AbsolutePosition - frame.AbsolutePosition)[Axis]
	local axisMax = (frame.AbsoluteSize - frame.Slider.AbsoluteSize)[Axis]
	
	local axis2 = math.max (axis, 0) or math.min (axis, axisMax) 
	axis = axis2
	
	return axis
end 

runService.RenderStepped:connect(function()
	-- Scrolling	
	local x = getAxis ('X', hor)
	local y = getAxis ('Y', vert)
	
	vert.Slider.Position = UDim2.new (0, 0, 0, y)
	hor.Slider.Position = UDim2.new (0, x, 0, 0)
end)