The Clear function clears the segments of the
Trail. This means that any trail that has been drawn will be erased when this function is called, even if that segment’s
Trail/Lifetime duration has not yet been reached.
While this is less noticeable for trails with shorter lifetimes, this is useful when cleaning up trails that have a longer lifetime, or for cases where the trail is removed when a certain game action occurs.
Calling this function will only affect old segments that have already been done. It will not affect the drawing of any new trail segments after this function call. If you would like to clear existing trail segments, and temporarily prevent new segments from being drawn, consider toggling the trail’s
Trail/Enabled property to false at the same time.
Clearing and Disabling a Trail
This example explains how to both clear a trail’s drawn segments and disable the trail to prevent new segments from being drawn. New segments will not be drawn until the trails
Trail/Enabled property is set to
In order for this example to be properly demonstrated, we must first create a
BasePart that will be the parent of our trail.
Then, we create two attachments, attachment0 and attachment1, both parented to part. The positions of these two attachments, more importantly the distance between them, determines where the trail is drawn as part moves.
For these attachments to create a trail as described, we create a new Trail and parent it to part. We then connect attachment0 to
Trail/Attachment0 and attachment1 to
To demo that the
Trail/Clear function erases any existing trail segments, the example relies on
TweenService/Create to move part back and forth to constantly draw a trail. Every 3 seconds of this motion, the trail segments are cleared and the trail is toggled between disabled and enabled.
In order for the example to work properly, the example implements a function named
tweenPart that tweens the part back and forth