Tween ends up rotating part instead of moving it

Hello,

So I have a hand mesh welded to a part and have a script in the part that activates tween service after touching the trigger which will then make it move forward and back and look as if the hand were to be reaching out and in. However, when the tween plays, not only does the part move but for some reason rotates completely messing up.

Clip of what things should be looking like:


Just moving out and back in, pretty much it.

How things are looking like:

I have no idea what’s causing this, I’ve already looked this problem up and messing around with things a bit but no luck yet.

How things are set up:
image

The code inside the script:

local trigger = script.Parent.Parent.trigger
local holdpart = script.Parent.Parent.holdingpart
local Debounce = false
local model = script.Parent.Parent
local TweenService = game:GetService("TweenService")
local tween = TweenService:Create(holdpart, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(-1036.343, -4.284, 929.96)})
local tween2 = TweenService:Create(holdpart, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(-1037.543, -4.284, 929.96)})

trigger.Touched:Connect(function(hit)
	if not Debounce then
	if hit.Parent:FindFirstChild("Humanoid") then
	Debounce = true
	wait(1)
	tween:Play()
	wait(1)
	tween2:Play()
end
end
end)

I’d appreciate any assistance as this is something that’s pretty easy anyways but since I’m not so experienced in scripting right now I wouldn’t know right away. I’ve tried to fix this but it’s simply not working as intended. I hope this makes sense as I’m not the best at explaining.

Try tweening the position, and not the CFrame.

The first 3 numbers in a new CFrame value are the positions X, Y and Z. the next 3 numbers are the rotations. Since you have not set those other 3 numbers its automatically setting the orientation to 0,0,0.

Use position instead of CFrame or just put the Orientation values in the CFrame value
More info: CFrame | Roblox Creator Documentation

1 Like

Hey,

Ok so I sort of got an idea now how it would go but I’m still confused on what it would look like from what I already have. I tried a few things like adding

* CFrame.Angles(math.rad(#), #, #)

at the end of the first tween’s

CFrame = CFrame.new(-1036.343, -4.284, 929.96)

and it didn’t really work to say the least. I also tried adding a variable for CFrame that looks something like

local cf = CFrame.new(#, #, #) * CFrame.Angles(math.rad(#), #, #)

from what I seen on the developer hub but didn’t really work, at all. I’m still a bit confused sorry. The code I provided at first was from someone who helped me with something else but am not too sure how I would modify it for this issue.