PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

Enabled

Trail

bool

The Enabled property determines whether a Trail will be drawn or not. This Enabled property defaults to true.

When enabled is true, the trail will create segments between the current position of its Trail/Attachment0 and the position of the attachments in the last frame.

If enabled is set to false while a trail is drawing no new segments will be drawn, but any existing segments will be cleaned up naturally when they reach the end of their Trail/Lifetime. If you would like to clean up any existing segments, you can use the Trail/Clear function at the same time.


Code Samples


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 true.

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 Trail/Attachment1.

To demo that the Trail/Clear function erases any existing trail segments, the example relies on TweenService’s 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 15 studs.


Setting a Trail's Enabled Property

This example demonstrates the the effects of enabling and disabling a Trail object.

In order to do this, we must first create a BasePart, part, which will be the parent of the 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 Trail/Attachment1.

In this example, we indicate whether the trail is enabled or disabled by changing the color of the Trail’s parent part. When the trail is enabled, part is green. Part is red when the trail is disabled. The enabled property switches every 5 seconds.

Finally, to demo the trail’s enabled state, the example relies on TweenService’s TweenService/Create to move part back and forth. As the part moves, the trail is drawn or not drawn depending on the state of the enabled property.