Anyone know why this goes to orgin of the map when I run it?

I’m currently making a robotic cat arm that moves towards a button. Here’s my code:

local CatArm = script.Parent
local Primary = CatArm.PrimaryPart

local TweenInformationA = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local TweenInformationB = TweenInfo.new(0.3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0)

local PositionA = TweenService:Create(Primary, TweenInformationA, {
	CFrame = CFrame.new(Vector3.new(-19.3, 121.3, -334.65))
})

local OrientationA = TweenService:Create(Primary, TweenInformationA, {
	CFrame = CFrame.Angles(math.rad(-65), 0, 0)
})

local PositionB = TweenService:Create(Primary, TweenInformationB, {
	CFrame = CFrame.new(Vector3.new(-19.3, 121.3, -334.65))
})

local OrientationB = TweenService:Create(Primary, TweenInformationB, {
	CFrame = CFrame.Angles(math.rad(0), 0, 0)
})

repeat
	PositionA:Play()
	OrientationA:Play()
	wait(1)
	PositionB:Play()
	OrientationB:Play()
	wait(1)
until nil

Note: Kinda new to using CFrame.

These 2 lines here

local OrientationA = TweenService:Create(Primary, TweenInformationA, {
	CFrame = CFrame.Angles(math.rad(-65), 0, 0)
})

and

local OrientationB = TweenService:Create(Primary, TweenInformationB, {
	CFrame = CFrame.Angles(math.rad(0), 0, 0)
})

When you use CFrame.Angles, it’s purely rotation data about a cframe, no position data. So what the game does is make it so that if you use CFrame.Angles by itself the blank position data will be 0,0,0 in position. So you’d need to do

local OrientationA = TweenService:Create(Primary, TweenInformationA, {
	CFrame = CFrame.new(-19.3, 121.3, -334.65) * CFrame.Angles(math.rad(-65), 0, 0)
})

instead

Another thing to note is when you do this down here it won’t reset the orientation back to the original. That’s not how CFrame works.

CFrame.Angles(math.rad(0), 0, 0)
1 Like