Motor6D Tween doesn't work as expected

  1. What do you want to achieve? Keep it simple and clear!

I wanna make the arm of my npc go up in the air

  1. What is the issue? Include screenshots / videos if possible!

The issue is that it goes to another position and orientation, idk why

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local rotatetweenarm = game:GetService("TweenService"):Create(trollbomb:WaitForChild("Body"):WaitForChild("Fists"):WaitForChild("RightFist"):WaitForChild("Motor6D"), TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {C0 = CFrame.new(Vector3.new(45.769, 23.974, -56.777))  CFrame.Angles(56.459, math.rad(-29.757), -65.066)})```

-- its a bit messy(the tween) as its only one i use in the entire code so why need to assign 30 bajillion variables

local TweenService = game:GetService("TweenService")

-- References to the parts and Motor6D
local part1 = workspace.Part1
local part2 = workspace.Part2
local motor = part1:FindFirstChildOfClass("Motor6D")

if not motor then
    motor = Instance.new("Motor6D")
    motor.Part0 = part1
    motor.Part1 = part2
    motor.Parent = part1
end

-- Function to create and play a tween for Motor6D's C0 property
local function tweenMotor6D(motor6d, targetC0, duration)
    local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
    local goal = {C0 = targetC0}
    local tween = TweenService:Create(motor6d, tweenInfo, goal)
    tween:Play()
end

-- Example usage
local targetC0 = motor.C0 * CFrame.Angles(0, math.rad(90), 0) -- Rotate 90 degrees around Y-axis
local duration = 2 -- Duration in seconds

tweenMotor6D(motor, targetC0, duration)

this literally looks AI generated no offense

Do you try a script at work with you? I don’t know sometimes I forgot.

So im guessing you want to use world space coordinates relative to the world?

Then you can try using this function to convert it to object space. I also recommend using CFrame.fromOrientation

local motor = script.Parent
local target = workspace.Target

local function worldCFrameRotationToC0ObjectSpace(motor6DJoint,worldCFrame)
	local part1CF = motor6DJoint.Part1.CFrame
	local part0 = motor6DJoint.Part0
	local c1Store = motor6DJoint.C1
	local c0Store = motor6DJoint.C0
	local relativeToPart0 = part0.CFrame:inverse() * worldCFrame * c1Store
	
	local goalC0CFrame = relativeToPart0
		
	return goalC0CFrame
end

while true do
	task.wait()
	motor.C0 = worldCFrameRotationToC0ObjectSpace(motor, target.CFrame)
end

i want to do it by a tween, so it looks smooth, and i already do the inverse trick when setting motor6d’s

i had a stroke while reading this

That is really something wrong we have to fix it otherwise I’m getting lost

my bad, it was because of another line interfering with the motor, thanks anyways!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.