Need help with tweening rotation

I was looking to create a claw machine but I’m currently stuck on closing the claws when the machine is down. Instead of rotating how I want them to, they rotate into the wrong positions.

The rotation of Prong1.Union, which is incorrect: image-6

The rotation: Video Unavailable

Below is the script that has the desired rotations and how it is handled.

local targetRotations = {
    Prong1 = Vector3.new(-73.502, 90, 180),
    Prong2 = Vector3.new(15.002, -150, -180),
    Prong3 = Vector3.new(32.501, -30, 180)
}

for _, prong in pairs(prongs) do
    local prongPivot = prong.Union:GetPivot()
    print(prongPivot.Position)

    local targetRotation = targetRotations[prong.Name]
    local rotationX, rotationY, rotationZ = targetRotation.X, targetRotation.Y, targetRotation.Z
    local targetCFrame = CFrame.new(prongPivot.Position) * CFrame.Angles(math.rad(rotationX), math.rad(rotationY), math.rad(rotationZ))
    local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
    local tween = TweenService:Create(prong.Union, tweenInfo, {CFrame = targetCFrame})
    tween:Play()
end

I’ve been trying multiple things for the past 2 days, haven’t found anything to work.

Hello! I don’t know if this will work, but it might be worth a try. In order to tween the claw parts to the right position, You could duplicate each claw with “Ctrl” + “D”. Then, Move them to the exact position and rotation you want the other claws to close to. Then change the duplicated claws’ transparency to 1 and CanCollide to false. Then, when you want to close the visible claws, tween their CFrames to their corresponding invisible claw’s CFrame. I’ve done this before with doors, etc. and It usually works. However, I cannot ensure it will work. Hope this helps!!

1 Like

weld the claws to the main body

It looks like what you are trying to do is keep the three claw parts of the machine to rotate correctly, like an actual claw machine. To do this, what you can try doing is welding the part with Motor6D and tweening the primary part.

1 Like

The primary part of what? The model?

Here’s what I set up as of right now:

image

And the properties of the Motor6D :

image

(DIDNT END UP USING THIS - REFER TO SOLUTION)

Thank you! What I did was tween the position of the claw to that other transparent part and that fixed my problem that I’ve been battling for days.

Not sure why I didn’t think of that earlier :sweat_smile:

Glad I could help!! :smile: Good luck on your project.