I am coding a Zipline, but I’ve run into an error. This video will probably explain the issue:
I don’t want this to be happening, I want the character to keep moving in the same direction, not turning around. I can’t use Position or Orientation, as that would probably break the character using the Zipline.
Script
StartPrompt.Triggered:Connect(function(Player)
if CharacterValue.Value then return end
StartPrompt.Enabled = false
EndPrompt.Enabled = false
local Character = Player.Character
CharacterValue.Value = Character
local Humanoid = Character.Humanoid
local Animator = Humanoid.Animator
local HRP = Character.HumanoidRootPart
local ZipAnim
local Distance = (Character.HumanoidRootPart.Position - EndZip.NeonCore.Position).Magnitude
local Time = Distance / 25
local Diff = 5
local Diff2 = 2.6
local RotateP = 0
local Pos = CFrame.new(EndPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0))
Pos *= CFrame.Angles(0,math.rad(180),0)
local Tween = TweenService:Create(
HRP,
TweenInfo.new(
Time,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
),
{
CFrame = CFrame.lookAt(EndZip.NeonCore.Position, StartZip.NeonCore.Position) * CFrame.new(0,Diff2,0)
}
)
HRP.Anchored = true
HRP.CFrame = CFrame.new(StartPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0))
HRP.CFrame = CFrame.lookAt(StartZip.NeonCore.Position, EndZip.NeonCore.Position) * CFrame.new(0,Diff2,0)
if Humanoid.RigType == Enum.HumanoidRigType.R15 then
ZipAnim = Animator:LoadAnimation(ReplicatedStorage.Animations.ZipLine.AnimR15)
elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
ZipAnim = Animator:LoadAnimation(ReplicatedStorage.Animations.ZipLine.AnimR6)
end
Tween:Play()
ZipAnim:Play()
Tween.Completed:Wait()
ZipAnim:Stop()
HRP.Anchored = false
CharacterValue.Value = nil
StartPrompt.Enabled = true
EndPrompt.Enabled = true
end)
Or perhaps your not at all. This is simply a position tween. I noticed that your CFrame.lookAt() for the tween is looking at the start of the zip line. That’s probably why its turning around.
In your last post, you said you used something called look at but it would break because the player was to low. What if you just changed the player’s position do they go over the zip line, then when it breaks it will look right.
That would stop the rotating though. You need to make the same problem that happened here: CFrame.lookAt breaking position then solve that problem so this problem doesn’t exist anymore. You make a problem to solve a problem, then you solve that problem with an easier solution, right?
Your tween goal should probably be something like this:
--Position of the Opposite end
local goalPos = EndZip.NeonCore.Position
--Look 5 studs behind the position of the opposite end (assuming its front face is pointed toward the start position)
local goalLookAt = goalPos + ((EndZip.NeonCore.LookVector * Vector3.new(1,0,1)) * -5) --Ignores the Y coordinate so no tilting
local goalFrame = CFrame.lookAt(goalPos, goalLookAt)
You may not even really need to clear the Y coordinate depending on the tilt of the end part. In that case you can just remove the Vector3 from the calculation.