[Please Help] Help With Checking if two GUIs are Touching

Hi.

  1. What do you want to achieve? I am trying to make a script that will tell whether two screen gui Image Buttons are touching.

  2. What is the issue? My script doesn’t seem to be working.

My script so far (It doesn't work)
local gui = script.Parent.Parent
local frame = script.Parent.Parent.Parent.FakeFrame
local distance = nil

while true do
	distance = math.abs((gui.AbsolutePosition - frame.AbsolutePosition).Magnitude)
	if distance > (frame.AbsoluteSize.X / 2) then
		script.Parent.Value = false
	else
		script.Parent.Value = true
	end
	print(distance)
	wait(.1)
end

The script prints out 0 and there are no errors.

The Explorer:

image
Note: I am trying to make sure that the object called slider stays inside the element called FakeFrame.

  1. What solutions have you tried so far? I searched on the Developer Forum, but I couldn’t find anything. I tried using .Magnitude with .AbsoluteSize, but it didn’t work.

Please tell me if you have any questions about this post! :smile:

Edit: Not sure of this helps, but both the Image Buttons have an Anchor Point of (0, 0.5)

Edit 2: While playing around with it, I changed both their anchor points to (0.5, 0.5) and now all it prints out is 28.799987792969

1 Like

I do not know how to do this but I have found some useful links that might help you.

Hope this helps

2 Likes