Help with trails

Hey there! I’m trying to add trails to all the characters in my game and I just want to know if I can add trails to each part of the player (like one trail on each body part) and if so, how would I do it? (I tried adding instances to each body part but they wouldn’t show)

1 Like

Have you tried looping through the Character’s Children, and checking if each object is a BasePart? You could reference your trail inside ReplicatedStorage to clone it for later use, to make it easier that way

for _, Object in pairs(Character:GetChildren()) do
    if Object:IsA("BasePart") then
        local TrailClone = game.ReplicatedStorage.Trail:Clone()
        TrailClone.Parent = Object
    end
end

I tried to implement this into my script by replacing the instances with your script thought it didn’t work. did I get something wrong?

here’s the script I’m using (without modification):

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local trail = game.ServerStorage.Trail:Clone()
		trail.Parent = char.Head
		local attachment0 = Instance.new("Attachment",char.Head)
		attachment0.Name = "TrailAttachment0"
		local attachment1 = Instance.new("Attachment",char.HumanoidRootPart)
		attachment1.Name = "TrailAttachment1"
		trail.Attachment0 = attachment0
		trail.Attachment1 = attachment1
	end)
end)

This would be the proper script:

game.Players.PlayerAdded:Connect(function(player)
		player.CharacterAdded:Connect(function(char)
			for i, v in pairs(char:GetChildren()) do
				if v:IsA("BasePart") then
					local attachment0 = Instance.new("Attachment", v)
					attachment0.Name = "attachment0"
					attachment0.Position = Vector3.new(0,0.2,0)

					local attachment1 = Instance.new("Attachment", v)
					attachment1.Name = "attachment1"
					attachment1.Position = Vector3.new(0,-0.2,0)
					local trail = game.ServerStorage.Trail:Clone()
					trail.Parent = v

					trail.Attachment0 = attachment0
					trail.Attachment1 = attachment1
				end
			end
		end)
	end)
1 Like

I labled player and char but it gave me this error

Script does work for me, so I don’t really know what you’re doing?

Do you use the script I sendt above, or did you add in other stuff, if so please share the script.

Looks like I had forgotten a line in the code, should work now!
Sorry about that

1 Like

it works! thank you so much for your help!

1 Like