I’m trying to find the percentage of how much a GUI object is inside a frame. For example, if the subject is exactly inside a frame then, it will be 100%. If it’s halfway inside then it would be 50%. Size and Positions also matter too. I’ll be so much thankful if anyone can help me.

Detection Script:

function DetectIfInside(gui1, gui2) -----some parameter you can put your GUI1 and GUI2 in
local gui1_topLeft = gui1.AbsolutePosition
local gui1_bottomRight = gui1_topLeft + gui1.AbsoluteSize
local gui2_topLeft = gui2.AbsolutePosition
local gui2_bottomRight = gui2_topLeft + gui2.AbsoluteSize
return ((gui1_topLeft.x < gui2_bottomRight.x and gui1_bottomRight.x > gui2_topLeft.x) and (gui1_topLeft.y < gui2_bottomRight.y and gui1_bottomRight.y > gui2_topLeft.y)) --- return their values
end

thx for using my script anyway i got lot of message from people telling me how to find percentage etc. what i know far is that you must substract gui1 and gui2 position then divide it by the position of gui1 and then times it by 100 here is the formula Percentage Change - Percentage Increase and Decrease | SkillsYouNeed or you can work out the area also i recomend what @crimcat said

Well no problem. Anyway about what’re you saying, I know the cause of the bug that I’m having right now but I don’t know how to multiply it by a 100 as it says “attempt to perform arithmetic (div) on UDim2”

local main = script.Parent.Frame
local overlapper = script.Parent.overlapper
local subract = main.Position - overlapper.Position
local divide = subract / main.Position
local answer = divide * 100
print(answer)

Also i’m not doing percentage changes, I only want to know the percentage of overlapping.

What i know is that you can only plus or substract it div and mul isnt suported with the help of a for i loops you can basicaly do a repeated subtraction which is division but with substraction What is Repeated Subtraction? Definition, Facts, Method, Examples.

The absolute position of it can be interpretted as the position. So say we got the scale, say 0.5 on the x and 0.6 on the y then the position is simply that * the viewport size