trying to make a part slowly follow another cause I wanna make a character like rain world.
Im trying to get another part to follow torso so It is kinda like a snake
code btw:
local Character = script.Parent
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local Torso = Character:WaitForChild("Torso",3)
if Character.Name == "StarterCharacterScripts" then
return
end
local TweenService = game:GetService("TweenService")
local Standing = false
local AlignPos = Instance.new("AlignPosition",Character.Torso)
AlignPos.Attachment1 = Humanoid.RootPart:FindFirstChildWhichIsA("Attachment")
AlignPos.Attachment0 = Torso:FindFirstChildWhichIsA("Attachment")
local BPOffset
Humanoid.Changed:Connect(function(changed)
end)
local Character = script.Parent
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local Torso = Character:WaitForChild("Torso", 3)
if Character.Name == "StarterCharacterScripts" then
return
end
local AlignPos = Instance.new("AlignPosition", Torso)
AlignPos.MaxForce = 1000 --how strong is the force? (if below 5 you may turn to the dark side and become a sith)
AlignPos.Responsiveness = 5 --higher = slower
AlignPos.Attachment1 = Humanoid.RootPart:FindFirstChildWhichIsA("Attachment")
AlignPos.Attachment0 = Torso:FindFirstChildWhichIsA("Attachment")
local BPOffset = Instance.new("BodyPosition", Torso)
BPOffset.MaxForce = Vector3.new(4000, 4000, 4000) --torso will lag behind if this aint ere
BPOffset.D = 10 --dampen
BPOffset.P = 1000 --how strong are ye?
--update the position based on the humanoidrootpart's movement
game:GetService("RunService").Heartbeat:Connect(function()
if Humanoid.MoveDirection.Magnitude > 0 then
BPOffset.Position = Humanoid.RootPart.Position + Vector3.new(0, 3, 0)-- ya can adjust the offset for some smooth following
end
end)