PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

LightEmission

Trail

float

The LightEmission Trail property sets how much the Trail/Color|Colors of the trail are blended with the colors behind them. LightEmission uses additive blending to combine the colors, meaning the RGB values of the colors are added together to determine the displayed color. This addition is weighted by the value of LightEmission.

When changed this property instantly affects all particles owned by the emitter, both current and future particles.

Note

This property is not related to the dynamic lighting engine of Roblox. If you need your trail to emit light, it is recommended to create parts with PointLight that follow the path of the trail.


Code Samples


Creating a Trail that Emits Light

This example demos the functionality of the light emission property of the 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 set the light emission to 1, the maximum possible value on a scale from 0 to 1. While this example does not create a part, containing a PointLight, that follows the trail around, it is recommended to do so.

Finally, to demo the trail’s light emission, 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
trail.LightEmission = 1

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