Properties
Attachment
|
Determines where the Trail will start drawing its segments. |
Attachment
|
Determines where the Trail will start drawing its segments. |
ColorSequence
|
The color of the trail segments throughout the lifetime of the trail. |
bool
|
Toggles whether a trail will be drawn or not. |
bool
|
If set to true, the trail textures will always face the camera. |
float
|
Duration of the trail in seconds. |
float
|
Sets how much the colors of the trail are blended with the colors behind them. |
float
|
Sets how much the Unlike the For instance, let’s consider what happens to the trail if we change lighting’s Note
|
float
|
Sets the maximum length of the trail. |
float
|
Minimum length of a trail’s segment in studs. |
Content
|
The texture to display on the trail. |
float
|
Sets length of texture if |
TextureMode
|
Sets how the Texture will be drawn. |
NumberSequence
|
Sets the transparency of the Trail’s segments over the trail’s |
NumberSequence
|
A |
bool
|
Determines if an |
string
[ReadOnly]
[NotReplicated]
|
A read-only string representing the class this |
int
[ReadOnly]
[NotReplicated]
[Deprecated]
|
The cost of saving the instance using data persistence. |
string
|
A non-unique identifier of the |
Instance
[NotReplicated]
|
Determines the hierarchical parent of the |
bool
|
A deprecated property that used to protect |
bool
[Hidden]
[NotReplicated]
[Deprecated]
|
string
[ReadOnly]
[NotReplicated]
[Deprecated]
|
Functions
void
|
Clears the segments of the trail. |
void
|
This function destroys all of an |
Instance
|
Create a copy of an object and all its descendants, ignoring objects that are not |
void
|
Sets the |
Instance
|
Returns the first ancestor of the |
Instance
|
Returns the first ancestor of the |
Instance
|
Returns the first ancestor of the |
Instance
|
Returns the first child of the |
Instance
|
Returns the first child of the |
Instance
|
Returns the first child of the |
Instance
|
Variant
|
Returns the attribute which has been assigned to the given name |
RBXScriptSignal
|
Returns an event that fires when the given attribute changes |
Dictionary
|
Returns a dictionary of string → variant pairs for each of the |
Objects
|
Returns an array containing all of the |
string
[NotBrowsable]
|
Returns a coded string of the |
Array
[CustomLuaState]
|
Returns an array containing all of the descendants of the instance |
string
|
Returns a string describing the |
RBXScriptSignal
|
Get an event that fires when a given property of an object changes. |
bool
[CustomLuaState]
|
Returns true if an |
bool
|
Returns true if an |
bool
|
Returns true if an |
void
[Deprecated]
|
Sets the object’s Parent to nil, and does the same for all its descendants. |
void
|
Sets the attribute with the given name to the given value |
Instance
[CustomLuaState]
[CanYield]
|
Returns the child of the |
Objects
[Deprecated]
|
Returns an array of the object’s children. |
Instance
[Deprecated]
|
void
[Deprecated]
|
Instance
[Deprecated]
|
Objects
[Deprecated]
|
bool
[Deprecated]
[CustomLuaState]
|
bool
[Deprecated]
|
void
[Deprecated]
|
Events
RBXScriptSignal
|
Fires when the |
RBXScriptSignal
|
Fires whenever an attribute is changed on the |
RBXScriptSignal
|
Fired immediately after a property of an object changes. |
RBXScriptSignal
|
Fires when an object is parented to this |
RBXScriptSignal
|
Fires when a child is removed from this |
RBXScriptSignal
|
Fires when a descendant is added to the |
RBXScriptSignal
|
Fires immediately before a descendant of the |
RBXScriptSignal
[Deprecated]
|
Code Samples
Creating a Part With a Basic Trail
This example demos the functionality of trails.
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 set the Trail/Color
to a fade between blue and white using a DataType/ColorSequence
. For more info on how to set a trail’s color in a script, see the Trail/Color
's documentation.
Finally, to demo the alignment the example relies on TweenService
's TweenService/Create
to move part back and forth. As the part moves, the trail is drawn.
-- Create a new BasePart
local part = Instance.new("Part")
part.Parent = game.Workspace
part.Anchored = true
part.Position = Vector3.new(0,5,0)
-- Create 2 attachments
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Parent = part
attachment0.Position = Vector3.new(-2,0,0)
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Parent = part
attachment1.Position = Vector3.new(2,0,0)
-- Create a new Trail
local trail = Instance.new("Trail")
trail.Parent = part
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
color1 = Color3.new(15/255,127/255,254/255)
color2 = Color3.new(255/255,255/255,255/255)
trail.Color = ColorSequence.new(color1, color2)
-- Tween part to display trail
local TweenService = game:GetService("TweenService")
local dir = 15
while true do
dir = dir*-1
local goal = {}
goal.Position = part.Position + Vector3.new(0,0,dir)
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
wait(5)
end