I’m attempting to create a line between two points using a frame (Vector2). The first point is simply the center of the screen, while the second is a white dot but I’m not sure what I’m doing.
Here’s the code I’m using:
local startPosition = Camera.ViewportSize / 2 --center of the screen
local endPosition = Vector2.new(ScreenPosition.X, ScreenPosition.Y) --white dot
local line = Instance.new("Frame")
local length = (endPosition - startPosition).magnitude
local angle = math.atan2(endPosition.Y - startPosition.Y, endPosition.X - startPosition.X)
line.Size = UDim2.new(0, length, 0, 2)
line.Position = UDim2.new(0, startPosition.X, 0, startPosition.Y)
line.Rotation = math.deg(angle)
line.Parent = script.Parent.Parent
This is what is happening:
The line should be from my mouse (center of the screen) to the white dot on that part.
It looks like the line is being drawn correctly but it’s just misplaced.
The line is parented to a ScreenGui with IgnoreGuiInset
set to true.