I am trying to create a Zipline, and I want that everything should be automated. What I’m currently doing is Orientating the Player’s character by an attachment’s position. But this kinda breaks the positioning. Here are 2 problems, but removed the CFrame.lookAt()
line.
With lookAt()
Without
lookAt()
Script
EndPrompt.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 - StartZip.NeonCore.Position).Magnitude
local Time = Distance / 25
local Diff = 5
local Pos = CFrame.new(StartPrompt.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 = Pos
}
)
HRP.Anchored = true
HRP.CFrame = CFrame.new(EndPrompt.Parent.WorldPosition + Vector3.new(0,Diff,0))
-- the line
HRP.CFrame = CFrame.lookAt(EndZip.NeonCore.Position, StartZip.NeonCore.Position)
RunService.Stepped:Wait()
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
if WaysValue.Value == true then
EndPrompt.Enabled = true
else
EndPrompt.Enabled = false
end
end)
You can clearly guess what I’m doing. How would I fix this issue?