How do you "draw" on a part?

I want to make something that when it is moved, it draws its path on the part, but I do not know how to write a script that makes the part draw.

One example of what I am talking about is the pencil in Epic Minigames where the player controls the pencil and the pencil draws on a part. There are several videos of this minigame that you can look up if you do not know what I am talking about.

If anyone knows how to do this I would appreciate it!

You may be thinking of trial effect which leaves a trail in its place

You would project a ray from a 2d point and then see if the ray hit the thing. From there its the same process as bullet holes