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




The LightInfluence property sets how much the trail is influenced by the lighting around it. The property can be set to a value from 0 to 1, with 1 being the most influenced and 0 be the least influenced.

Code Samples

Setting a Trail's Light Influence

This example demos the trail’s light influence property.

In order to do this, we must first set Lighting's Lighting/Brightness to 0. This is done to create a better demo lighting to demo the differences in the trail’s appearance when the light influence property changes.

Next, we 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 initially set the LightInfluence property to 1. Then, every 5 seconds we increment the property so that it toggles between 0 and 1. When the value is 0, the trail appears much brighter because it is not influenced by Lighting’s low brightness as compared to when the value is 1.

Finally, to demo the property the example relies on TweenService's TweenService/Create to move part back and forth. As the part moves, the trail is drawn.

-- Set Lighting's brightness to 0
game.Lighting.Brightness = 0

-- 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.LightInfluence = 1

-- Tween part to display trail
local TweenService = game:GetService("TweenService")

local dir = 15
local influence = 1
while true do
	dir = dir*-1

	influence = influence*-1
	trail.LightInfluence = trail.LightInfluence+influence

	local goal = {}
	goal.Position = part.Position + Vector3.new(0,0,dir)
	local tweenInfo = TweenInfo.new(5)
	local tween = TweenService:Create(part, tweenInfo, goal)