Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I detect if a GuiObject is touching another GuiObject?

How would I detect if a GuiObject, like a frame, touches a certain GuiObject, like another frame and not any TextLabels in the way and print out "Frame is touching another frame." Here is a script that I tried, but it only worked if the frame was exactly on it.

local frame = script.Parent
local frame2 = script.Parent.Parent.HitFrame

if frame.Position == frame2.Position then
	print("Frame is touching HitFrame")
end


Note: frame2 has the same size of the first frame.

1 answer

its not too hard but u need to make it only by Offset not Scale Like This:

local Right = Me.Position - Me.Size.X / 2
local Left = Me.Position + Me.Size.X / 2

while wait() do
	if Gui.Position > Right and Gui.Position < Left then
		print("TOUCHED")
	end
end

1 comment

0

maybe this works

This discussion is preserved as it was. New answers, comments, and votes are closed.