Tween rotating in wrong direction

I want so tween would rotate the “arrow” part correct way. See attached video.

As you can see, the arrow is rotating but in wrong direction, something that a person would describe as a “360 NoScope”. I have tried googling, scrolling devforum for an hour, but still nothing.

Script
local function getOrien(target: BasePart): Vector3
	local orien: Vector3
	
	if target.CFrame.LookVector.X > 0.5 then
		orien = Vector3.new(0, 0, 0) 
	elseif target.CFrame.LookVector.X < -0.5 then
		orien = Vector3.new(0, 180, 0)
	end

	if target.CFrame.RightVector.X < -0.5 then
		orien = Vector3.new(0, -90, 0)
	elseif target.CFrame.RightVector.X > 0.5 then
		orien = Vector3.new(0, 90, 0)
	end
	
	return orien
end

local playArrow = function()
	arrow.Transparency = 0
	arrow.Position = Path["1"].Position
	arrow.Orientation = Vector3.new(0, 180, 0)
	
	for i, v in Path:GetChildren() do
		local target: BasePart = Path[i + 1]
		
		local posit = Path[i].Position
		local orien = getOrien(target)
		
		if i == 5 then
			tweenServ:Create(arrow, tweenTransp, {Transparency = 1}):Play()
		end
		
		tweenServ:Create(arrow, tweenPosit, {Position = posit}):Play()
		task.wait(0.5)
		
		tweenServ:Create(arrow, tweenOrien, {Orientation = orien}):Play()
		task.wait(0.15)
		
		if i == 7 then
			task.wait(1)
			break
		end
	end
end

Thanks!

1 Like

I hope it’s just me but your video is unwatchable

How and why is it unplayable though

“No video with supported format and MIME type found”

This is a Firefox issue. I cannot play any videos from devforum on Firefox, not just this, so I had to use Edge for devforum.

1 Like

Ah I see, I see, I’m guessing it’s their built-in blocker

1 Like

It’s pretty funny though LOL, you should leave it in as a “feature.”

Jokes aside, I think that it’s because rotating from y 180 to y -90 requires a 270 degree turn, I would do math like adding 90 degrees or 180 degrees to the current rotation rather than having a set rotation

1 Like

Alright, thanks! I am going to try that

1 Like

At the end I had to do this as solution.

		if currOrien.Y < 190 and currOrien.Y > 150 and orien == Vector3.new(0, -90, 0) then
			arrow.Orientation = Vector3.new(0, -179.99, 0)
			tweenServ:Create(arrow, tweenOrien, {Orientation = orien}):Play()
		elseif currOrien.Y < -150 and currOrien.Y > -160 and orien == Vector3.new(0, 180, 0) then
			local tween = tweenServ:Create(arrow, tweenOrien, {Orientation = Vector3.new(0, -179.99, 0)})
			tween:Play()
			tween.Completed:Connect(function() arrow.Orientation = Vector3.new(0, 180, 0) end)
		else
			tweenServ:Create(arrow, tweenOrien, {Orientation = orien}):Play()
		end
1 Like