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.
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.
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
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```
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.
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