I have a gui, and i wanna detect when another gui touches it or is inside of it
How can i do so?
I have found this function on another question.
function collidesWith(gui1, gui2) 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)) end
It should also work for your situation! Just check this everytime the GUI moves.