How do you tween a Motor6D.C0 with TweenService?

I’m trying to tween a Motor6D’s C0 CFrame but it keep resulting an error: [Unable to cast value to Object]

function TweenC0(Motor, EndCF)
	local prop = {CFrame = EndCF}
	local info = TweenInfo.new(0.1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
	return TweenService:Create(Motor, info, prop)
end

TweenC0(Motor6D.C0, CFrame.new(0,1,0))

I know I can use CFrame.lerp, however I want to use TweenService in my scenario, seems that there’s something wrong with the tween function?

TweenService:Create first argument requires an instance to tween.

The third argument, the property table, should be a mapping of property keys to goal values.

local function TweenC0(Motor, EndCF) -- always use local variables, TweenC0 has been made local
	local prop = {C0 = EndCF}
	local info = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	return TweenService:Create(Motor, info, prop)
end

local tween_instance = TweenC0(Motor6D, CFrame.new(0, 1, 0)
5 Likes

Does that mean C0 can not be tweened?

This means you have given a number, but the C0 property needs to be a CFrame. Can you paste the piece of code where you call this function?

My bad, I only gave 3 numbers but did not conclude them with CFrame.new, thanks for the help!

Hey I followed those same steps but it returned with the “Unable to cast value to Object” error, could you help me out?

1 Like