Is there a way to set cframe without changing a orientation?

Example is that you want to make an arm with a already default position and orientation set, now I want it to SET only a position of a arm, not with a orientation.

Can you give me any feedback? I can’t find anything in the forum!

Couldn’t you just use Part.Position?

i think that cframe is better because when i used a position, it will break a joints

Can you provide any further details of the problem?

You know that setting a cframe uses 2 arguments CFrame.new(position,orientation)
Now if you set the orientation blank, it will reset a orientation (which will be Vector3.new(0,0,0)) however if i add a orientation, i will not SET but it will ADD instead

You can set a CFrame orientation using this:
CFrame.new(Position) * CFrame.Angles(math.rad(Orient.X),math.rad(Orient.Y),math.rad(Orient.Z))
CFrame.Angles uses radians.

1 Like

ok i’ll try that! Thank you for your help!

i think it actually work, let me study more real quick!

I think it still didnt work, but it set the orientation 1 time

I still think that multiplying is like adding 2 cframes

Wait, so are you trying to offset the current orientation or just set?

it like you will pump a shotgun, which you need to offset it position without changing it orientation, i just want it to keep a orientation the same

function MoveCFrame(Pos,Ori,Part)

local tween = game:GetService("TweenService")

local NewOri = Ori

local cframes = CFrame.new(Part.Position + Pos) * CFrame.Angles(math.rad(Ori.X),math.rad(Ori.Y),math.rad(Ori.Z))

--CFrame.fromEulerAnglesXYZ(math.rad(Ori.X),math.rad(Ori.Y),math.rad(Ori.Z)

local twen = tween:Create(Part,TweenInfo.new(0.2),{CFrame = cframes})

twen:Play()

end

repeat

MoveCFrame(Vector3.new(-1,0,0),script.Parent.Orientation,script.Parent)

wait(1)

MoveCFrame(Vector3.new(1,0,0),script.Parent.Orientation,script.Parent)

wait(1)

until false

This is the script i used (which modify as you said already)
it was located in a left arm

You can offset a part in a specific direction without altering orientation using this:
Part.CFrame *= CFrame.new(0,0,-1)
This will move the part towards it’s LookVector by 1 stud.

it returns that the orientation of the arm is 0,0,0 O_O

Close, but not there yet.

CFrame.Angles does not equal orientation.

local cframeToChange = --some CFrame
local newPosition = --some vector3 position value you want to change
local cframeToChangeOrientationOnly = cframeToChange - cframeToChange.Position --remove position component from CFrame.

part.CFrame = CFrame.new(newPosition)*cframeToChangeOrientationOnly 
--Add in new position component
--Alternatively you can just add the new position
part.CFrame = cframeToChangeOrientationOnly + newPosition

10 Likes

can you give me an example? I pretty not sure what to put