Making a frame face another frame

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want a frame to face at the position of another frame

  2. What is the issue? Include screenshots / videos if possible!
    I can’t get the frame to face the other frame position

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looking in the developer hub but I didn’t find anything useful I only found how to make the frame rotate to the mouse position

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Already said what i needed to do

local frame = script.Parent
	function getAngleInDegrees(point1, point2)
			    point2 = point2 - point1
			    angle = math.atan2(point2.y, point2.x)
			    return math.deg(angle)
			end

	script.Parent.Rotation = getAngleInDegrees(frame.AbsolutePosition,script.Parent.Parent.Heart.AbsolutePosition)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

This works for me:

local screen = script.Parent
local a = screen.A
local b = screen.B

while wait() do
	local diff = b.AbsolutePosition - a.AbsolutePosition
	local angle = math.atan2( diff.Y, diff.X )
	a.Rotation = math.deg(angle)
	b.Position = UDim2.new(0, 500 + math.sin(tick())*300, .5, 0)
end

frame_pointer.rbxm (2.7 KB)

bfwfjL0Z4Z

4 Likes

alr imma test it and see if it works