How to get selected color and material from parts section in model tab with a script

I was making a plugin that would let me make grass out of a selected part. I wanted it to have the same color and material as the one selected in the parts section in the model tab. I’ve done a few searches but I couldn’t find anything about it
(image below)

Is it possible to do this? Let me know