How to Script a Dynamic Trail Mesh in Roblox Studio

I dev in roblox studio. The game engine only has functions in its api to manipulate the vertices and uvs, nothing built in already. So how would i code a trail mesh like these:

For reference, these are the functions robox gives us. A few being AddTriangle() AddVertex() methods, GetPosition() and SetPosition() of a vertex, and GetUV() SetUV() coordinates.