How would I know if a UI object has been clipped

How would I detect with a script if a ui object has been clipped due to their parent having clipdecendents set to true?

2 Likes

calculate minimum x maximum x minimumy maximumy of the frame with clips descending enabled for ChildAdded if they have position property constantly get signal changed for their Position, Compare with your Min Values. If its lower than the minimum of X/Y or higher than the maximum X/Y then this means it’s being clipped since its outside the bounds, for size its the exact same where your comparing its position to the frames minimums and maximums.

2 Likes

The following function returns True if provided GuiObject is outside it’s parents bounding box.

function isClipped(uiObject: GuiObject)
	local parent = uiObject.Parent
	local boundryTop = parent.AbsolutePosition
	local boundryBot = boundryTop + parent.AbsoluteSize
	
	local top = uiObject.AbsolutePosition
	local bot = top + uiObject.AbsoluteSize
	
	local function cmpVectors(a, b) -- Compare is a is above or to the left of b
		return (a.X < b.X) or (a.Y < b.Y)
	end
	
	return cmpVectors(top, boundryTop) or cmpVectors(boundryBot, bot)
end
6 Likes