It is complex but I will keep it simple as possible.
I have a zipline system which uses CFrames to work properly but I wanted it to change to Position to make Diagonal Ziplines possible. However once I use the Position instead of the CFrame the entire code only works once and then never again, but this issue doesnt occur when using CFrames.
This is the code I use:
local function TravelTo(HRP, distance, location, proximityPrompt, offset)
HRP.Anchored = true
local humanoid = HRP.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.AutoRotate = false
end
local startPosition = proximityPrompt.Parent.Position
HRP.Parent:PivotTo(CFrame.new(startPosition.X, startPosition.Y, startPosition.Z))
HRP.CFrame = CFrame.new(HRP.Position.X, startPosition.Y, HRP.Position.Z) *
CFrame.Angles(0, math.rad(offset), 0)
local tween = TweenService:Create(
HRP,
TweenInfo.new(distance / (8 * 5), Enum.EasingStyle.Linear),
{CFrame = CFrame.new(location) * CFrame.Angles(0, math.rad(offset), 0)}
)
tween:Play()
task.spawn(function()
tween.Completed:Wait()
HRP.Anchored = false
if humanoid then
humanoid.AutoRotate = true
end
end)
end
for i, zipline in Ziplines:GetChildren() do
if zipline:IsA("Model") then
local Start = zipline:FindFirstChild("Start")
local ProxStart = Start:FindFirstChildOfClass("ProximityPrompt")
local End = zipline:FindFirstChild("End")
local ProxEnd = End:FindFirstChildOfClass("ProximityPrompt")
if Start and ProxStart and End and ProxEnd then
local Distance = (End.Position - Start.Position).Magnitude
ProxStart.Triggered:Connect(function(player)
TravelTo(player.Character.PrimaryPart, Distance, End.Position, ProxStart, -90)
end)
ProxEnd.Triggered:Connect(function(player)
TravelTo(player.Character.PrimaryPart, Distance, Start.Position, ProxEnd, 90)
end)
end
end
end
With CFrame:
Now instead of CFrame I use Position = location
I really dont know why this behaviour occurs and I have been stuck here for a long time. Not sure if I am doing something wrong but I really like to use the Position instead