How to make spotlight follow move cursor

I would like to make a flashlight that when you move your move it follow the cursor and even on walls and if you get farther from the wall it fades

At first I thought of attachments but I don’t know if it will work

Will work both with attachments or with regular part. Use Mouse.Hit.P, and make flashlight part or attachment CFrame change every render step to look at the mouse hit p

But how could I make it fade away if it’s too far