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…
however, it seems to work fine when tweening the a part’s orientation instead.
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)