Odd Tween Issue regarding Position

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

1 Like

Is there an error being thrown in your output?

Just an FYI, you can’t orientate the character with a vector like you can with CFrame since I last tried.

IIRC {Orientation = Vector3.new(x,y,z)} would throw a sort of error or just not work whatsoever, however I could be wrong since I’ve just used CFrame for positioning parts with TweenService.

I can’t test this theory right now though so you’ll need to confirm it.

1 Like

Nope, no error at all. I put out prints in the Triggered events and as soon I use it the second time it doesn’t print anything.

Also the character is just going in a straight line anyway and with my calculation Diagonals (along the Z (i think?) Axis) dont really work out, so thats why I want to use Positions ( the orientation is already done at the beginning of the function )

1 Like

You could use LookVector to get the correct orientation for the player.

It doesn’t matter if you use vectors or not because either way your orientation will still be incorrect.

This may help you with your issue:

2 Likes

I didn’t really think of that. I did find a simpler method (getting the models pivot orientation) but yours worked too so thanks man

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.