Here it is in action:
Code:
local RNS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local frame1 = script.Parent.frame
RNS.Heartbeat:Connect(function()
local mousePos: Vector2 = UIS:GetMouseLocation()
local disp: Vector2 = mousePos - frame1.AbsolutePosition
local angle: number = math.deg(math.atan2(disp.Y, disp.X)) + 90
frame1.Rotation = angle
end)
This already works, I’m just curious.
How does this work? Why do you need to add ‘90’ to the angle to make it work right? I’m only recently starting trigonometry so this is all new to me.