I need some help fixing a current problem with my zipline module, and its getting on my nerves. I’ve tried looking for videos, devforum blogs and other means to help with this problem, but none have helped. I’ve got the welding and alignment properly, I just need help stop the player from swaying back and forth.
Here is the code:
function Zipline:AttachPlayerToZipline(Player, A, B)
local Character = Player.Character
local HRP = Character.HumanoidRootPart
local HMD = Character.Humanoid
HRP.CFrame = CFrame.new(A.WorldPosition, B.WorldPosition)
HMD.PlatformStand = true
HRP.Massless = true
HRP.Anchored = false
local ZiplinePart = Instance.new("Part")
ZiplinePart.Size = Vector3.new(0.1, 0.1, 0.1)
ZiplinePart.Anchored = true
ZiplinePart.Transparency = 1
ZiplinePart.CanCollide = false
ZiplinePart.Name = "ZiplinePart"
ZiplinePart.Parent = A.Parent.Parent
ZiplinePart.Position = A.WorldPosition
local ZiplineAttachment = Instance.new("Attachment")
ZiplineAttachment.Parent = ZiplinePart
local AlignPosition = Instance.new("AlignPosition")
AlignPosition.ReactionForceEnabled = true
AlignPosition.MaxForce = 10000000
AlignPosition.MaxVelocity = math.huge
AlignPosition.RigidityEnabled = true
AlignPosition.Parent = ZiplinePart
local ziplineDirection = (B.WorldPosition - A.WorldPosition).Unit
HRP.CFrame = CFrame.new(HRP.Position, HRP.Position + ziplineDirection)
AlignPosition.Attachment1 = Character["Left Arm"].LeftGripAttachment
AlignPosition.Attachment0 = ZiplineAttachment
local anim = HMD.Animator:LoadAnimation(script.Zipline)
anim:Play()
game:GetService("TweenService"):Create(ZiplinePart, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Position = B.WorldPosition}):Play()
end
I recommend you to use an AlignOrientation object inside of the HumanoidRootPart to prevent the character from spinning so aggressively and to correct the direction that the character is facing. You can play with the Responsiveness and MaxTorque to get smoother results