Tween character's orientation without locking position

Hi! I’m currently trying to tween the orientation of a character so that it faces an object, but I’m unable to get it to properly orient. Using CFrames, it can orient itself fine, but I wanted to use the Orientation property since tweening the CFrame locks the character in place. However, when I try to tween the orientation, it doesn’t end very well…
52cd413a328c5be821e489e606051f12
however, it seems to work fine when tweening the a part’s orientation instead.
27535391fb0d72a326c529aac238d6a3

Here’s the code I have right now, I’m not particularly concerned about how it’s implemented as long as it can fit in a function (i.e. I don’t want to have to run a heartbeat connection with a CFrame:Lerp instead of tweening) and doesn’t lock the orientation.

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local localPlayer = Players.LocalPlayer
local character = localPlayer.Character

repeat task.wait() until game:IsLoaded()

local part = workspace:WaitForChild("Part")
local clickDetector = part.ClickDetector

local spawnLocation = workspace:WaitForChild("SpawnLocation")

local originalOrientation = part.Orientation

clickDetector.MouseClick:Connect(function()
	local lookAt = CFrame.lookAt(character.HumanoidRootPart.Position, spawnLocation.Position)
	local y, x, z = lookAt:ToOrientation()
	
	print(x .. " " .. y .. " " .. z)
	
	local tween = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, true)
	TweenService:Create(character.HumanoidRootPart, tween, {Orientation = Vector3.new(math.deg(y), math.deg(x), math.deg(z))}):Play()
end)
1 Like

One of the possible solutions to your problem is finding the orientation using CFrame.lookAt() and then convert it to Vector3 Orientation using CFrame:ToAxisAngle() which you would then use to tween.