CFrame.LookVector not working in tweening

  1. I want to achieve a Tween that will make the part tween towards the direction of the humanoidRootPart

  2. it is not working and gives this error "TweenService:Create property named ‘CFrame’ cannot be tweened due to type mismatch (property is a ‘CoordinateFrame’, but given type is ‘Vector3’) "

local part = script.Parent
local tweenService = game:GetService("TweenService")


local tweenInfo = TweenInfo.new(5,Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0 ,false ,0)

local connection
local function hitFunction(hit)
	if hit.Parent:FindFirstChild("Humanoid") then

		local goals = {
			CFrame = part.CFrame * hit.Parent:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 100

		}
		local partTween = tweenService:Create(part, tweenInfo, goals)
		partTween:Play()
		connection:Disconnect()
	end
end
connection = part.Touched:Connect(hitFunction)

The error says that you’re trying to get a vector3 and not a CFrame.

Try this, this basically just creates a new CFrame.

CFrame = part.CFrame * CFrame.new(hit.Parent:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 100)

I also recommend you to detect if the humanoidrootpart exists before creating the goal.

local function hitFunction(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
        local HumanoidRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
        if HumanoidRootPart then
           	local goals = {
			CFrame = part.CFrame * CFrame.new(HumanoidRootPart.CFrame.LookVector * 100)
		}
     		local partTween = tweenService:Create(part, tweenInfo, goals)
	    	partTween:Play()
		    connection:Disconnect()
        end
	end
end