How do i make a part trail?

I want to make a trail that uses parts, like in the game slither.io. I know there is a particle effect that you can use. But i want to make it use parts that follow a head part.

The issue is that i cant seem to make it work. The head part uses CFrame to move. So hinges or ropes wont work. So i know i got to use CFrame to make the other parts to move as they should. Like if the head part rotates 90 degrees i want all the other parts when they reach that point to rotate also 90 degrees then. I can seem to figure it out how to make that happen.

Hey!

You can make a similar effect using your own decal with a simple particle emitter. You say that you know there is a particle effect, however parts aren’t really practical, at least in my opinion.

This will be both an easier and safer route to take.

Thanks,
Sam.

that wont work tho. Since i want to detect touches too.

What I can think of is create a Vector3 position every 0.1 seconds or so and make the other parts tween to that part.


So:

local Head = The head part
local BodyPart1 = body part

local TS = game:GetService("TweenService")
local TI = TweenInfo.new(Tween info here)

local VectortoMove

while wait(0.1) do
    VectortoMove = head.Position
    TS:Create(BodyPart1, TI, {Position = VectorMoveTo}
end
1 Like

Can you just keep a map of Position to CFrames and for every part that hits that Position, look up the CFrame you want to set and set it?

The only thing tho is that it wont make it rotate, it works and so. But how do i make it also rotate?
I tried changing the code a bit but it didn’t work. Here is what i tried:

local Head = workspace.SnakeHead_epicboyman3
local BodyPart1 = workspace.P1
local BodyPart2 = workspace.P2

local TS = game:GetService("TweenService")
local TI = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local VectortoMove1 = {}
local VectortoMove2 = {}

while wait(0.1) do
    VectortoMove1.CFrame = CFrame.new(Vector3.new(Head.Position.X, Head.Position.Y, Head.Position.Z), Vector3.new(Head.Orientation))
    VectortoMove2.CFrame = CFrame.new(Vector3.new(BodyPart1.Position.X, BodyPart1.Position.Y, BodyPart1.Position.Z), Vector3.new(BodyPart1.Orientation))
    TS:Create(BodyPart1, TI, VectortoMove1):Play()
    TS:Create(BodyPart2, TI, VectortoMove2):Play()
end```

I tried removin the Vector3.new() when defining the orientation. And that made it rotate. But it dont rotate the right amount or the right way now, https://gyazo.com/e59617e811d846e8cef7d59812e5d096

CFrame.new(Vector3.new(Head.Position.X, Head.Position.Y, Head.Position.Z), Vector3.new(Head.Orientation))

I would suggest changing that to

CFrame.new(Vector3.new(Head.Position.X, Head.Position.Y, Head.Position.Z), Head.Orientation)

for both of them, just put the orientation down, I don’t think the Vector3 part is needed

i know, thats what i just said. But that creates the effect that happens in the gyazo video i sent.

Here are some ways you can do that:

Trail class

There is a class dedicated for making trails.

Litterally a trail of parts

This code will leave a duplicate part behind the moving one:

local part = script.Parent
part:GetPropertyChangedSignal("CFrame"):Connect(function()
    local trailPart = part:Clone()
    trailPart.CanCollide = false
    trailPart.Anchored = true
    trailPart.Transparency = 0.5 --remove this if you want trail to be opaque
    trailPart.CFrame = part.CFrame
    trailPart.Parent = workspace
    game.Debris:AddItem(trailPart, 0.5) --change the second parameter to whatever you want
end)

But I’m afraid this will leave too many trail parts and will cause lag. If it will, you’ll need to implement debounce system into this code.

that wont work tho. Thats not what i mean by trail. Read the other posts first before commenting. Btw, here is what happens then https://gyazo.com/3b0c003efcf2a9ae84263545b9272ea7

I haven’t tested anything yet, but I have a feeling that lerping the parts to a set position behind the main part would work.

whats the diffrence between lerping and tweening? Shouldn’t tweening work aswell?

Try to connect all of your parts with Ball-in-socket constraint?

I got it:

local Head = workspace.SnakeHead_TOP_Crundee123
local BodyPart1 = workspace.P1
local BodyPart2 = workspace.P2

local TS = game:GetService("TweenService")
local TI = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local VectortoMove1 = {}
local VectortoMove2 = {}

while wait(0.1) do
    VectortoMove1.CFrame = Head.CFrame -- Just changed this
    VectortoMove2.CFrame = BodyPart1.CFrame -- And this
    TS:Create(BodyPart1, TI, VectortoMove1):Play()
    TS:Create(BodyPart2, TI, VectortoMove2):Play()
end

Sorry it took so long

2 Likes

Cool, thank you so much. I had no idea it was a so simple change needed

1 Like