Player Trail

Use Instance.new() to give the player their own trail.

by GalaxyGourmet

Author Avatar

Getting Started

To get things started, you'll need to insert either a Script or a LocalScript into StarterCharacterScripts.

Once you've done that, open up the script, and delete the print("Hello world!") line.

Creating the Trail and it's Attachments

In order to give the player a trail, we'll need to create one for them. And to create objects, we'd have to use Instance.new(). Type this in the script:

local trail = Instance.new("Trail")

Every trail needs two unique attachments, so we'll have to create those too.

local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")

Now we've created the trail and it's attachments for the player, but there are also properties that we must set.

Changing the Properties

We put the script in StarterCharacterScripts for a good reason. The script will be inside the player's character, where the HumanoidRootPart is, which is what will parent the trail and attachments.

local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")

trail.Parent = script.Parent.HumanoidRootPart
att0.Parent = script.Parent.HumanoidRootPart
att1.Parent = script.Parent.HumanoidRootPart

Now we're going to set the trail's attachments. As said above, trails must have two unique attachments.

local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")

trail.Parent = script.Parent.HumanoidRootPart
att0.Parent = script.Parent.HumanoidRootPart
att1.Parent = script.Parent.HumanoidRootPart
trail.Attachment0 = att0
trail.Attachment1 = att1

Trails are enabled by default, but there's nothing stopping you from setting Enabled to true.

local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")

trail.Parent = script.Parent.HumanoidRootPart
att0.Parent = script.Parent.HumanoidRootPart
att1.Parent = script.Parent.HumanoidRootPart
trail.Attachment0 = att0
trail.Attachment1 = att1
trail.Enabled = true

We'll now adjust the two attachments' position to spread them out.

local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")

trail.Parent = script.Parent.HumanoidRootPart
att0.Parent = script.Parent.HumanoidRootPart
att1.Parent = script.Parent.HumanoidRootPart
trail.Attachment0 = att0
trail.Attachment1 = att1
trail.Enabled = true
att0.Position = Vector3.new(.5, 0, 0)
att1.Position = Vector3.new(-.5, 0, 0)

After that, you can freely set the Lifetime of the trail, MinLength, MaxLength, and basically any other property.

Now test the game. If you did everything correctly, you should have a trail that follows you around.

img|80x75

Final Script

--Remember, this must be in StarterCharacterScripts
local trail = Instance.new("Trail")
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")

--Feel free to change other properties
trail.Parent = script.Parent.HumanoidRootPart
att0.Parent = script.Parent.HumanoidRootPart
att1.Parent = script.Parent.HumanoidRootPart
trail.Attachment0 = att0
trail.Attachment1 = att1
trail.Enabled = true
att0.Position = Vector3.new(.5, 0, 0)
att1.Position = Vector3.new(-.5, 0, 0)