local Drawing = {} Drawing.__index = Drawing function Drawing.new(type) if type == "Line" then local self = setmetatable({}, Drawing) -- Create UI frame for the line self.Instance = Instance.new("Frame") self.Instance.AnchorPoint = Vector2.new(0.5, 0.5) self.Instance.BorderSizePixel = 0 self.Instance.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("ScreenGui") or Instance.new("ScreenGui", game.Players.LocalPlayer:WaitForChild("PlayerGui")) -- Default values self.From = Vector2.new(0, 0) self.To = Vector2.new(100, 100) self.Thickness = 5 self.Color = Color3.new(1, 1, 1) self.Visible = true -- Apply initial properties self:Update() return self else error("Invalid Drawing type: " .. type) end end function Drawing:Update() if not self.Instance then return end if not self.Visible then self.Instance.Visible = false return end local distance = (self.To - self.From).Magnitude local direction = (self.To - self.From).Unit local angle = math.deg(math.atan2(direction.Y, direction.X)) self.Instance.Size = UDim2.new(0, distance, 0, self.Thickness) self.Instance.Position = UDim2.new(0, (self.From.X + self.To.X) / 2, 0, (self.From.Y + self.To.Y) / 2) self.Instance.Rotation = angle self.Instance.BackgroundColor3 = self.Color self.Instance.Visible = true end function Drawing:Remove() if self.Instance then self.Instance:Destroy() self.Instance = nil end end return Drawing