How to change the color of a trail through a script?

I need to change the color of a trail from a script because it has to match a random color that another instance has. I am aware, however, that trails require a color sequence, not a simple color3. If anyone has an idea of how I could set the whole trail to one color through a script I would appreciate it!

Trails are not required to have a color sequence, just set the trails color property to a Color3 value.

I have already tried that and it returned an error saying that it can’t set the color sequence to a color3 value.

You have to manually set it in properties first to a color3 value

When you’re in a pinch, you can create a Color Sequence that has two keypoints that are both the same color.

See this example below, taken from the ColorSequence page on Roblox’s Documentation website:

local colorSequence = ColorSequence.new{
    ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
    ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 0, 0))
}

In your case, your code may end up looking something like this (with some color properties swapped out of course. Color3.fromRGB will probably be the random color you’ve pulled from another instance instead):

local trail = workspace:WaitForChild("Part"):WaitForChild("Trail")

local colorSequence = ColorSequence.new{
    ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
    ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 0, 0))
}

trail.Color = colorSequence

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.