Making a material function to draw a polygon

I’m trying to re write this function to draw a polygon it was from HSLS script
but it does not seem to work in unreal any suggest how can I fix it?