When I set CFrame.Angle, it sets part position to (0,0,0)

I have a script:

while true do
	wait()
	local newCFrame = CFrame.Angles(math.rad(45), 0, 0)
	local offset = Vector3.new(0,1,-5)
	clone.WoodDoor:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame*CFrame.new(offset)) 
	
	clone.WoodDoor:SetPrimaryPartCFrame(newCFrame)

end

Basically, what it does is put the part in front of the player and sets the angle of the part to a specific number. However, when I set CFrame.Angles, it sets the part’s position to (0,0,0) and when I set the parts CFrame position, it sets it’s orientation to (0,0,0). Why is this happening, and how can I fix it?

local offset = Vector3.new(0,1,-5)

Try cframe instead of vector3. I am away so I can’t test it though.

1 Like

You forget to multiply the rotation to the new cframe.

while true do
	wait()
	local rotation = CFrame.Angles(math.rad(45), 0, 0)
	local offset = Vector3.new(0,1,-5)
	local newCFrame = CFrame.new(character.HumanoidRootPart.Position+offset)*rotation
	clone.WoodDoor:SetPrimaryPartCFrame(newCFrame)
end
1 Like

Thanks, but now i’m getting the error “invalid argument #1 (CFrame expected, got Vector3)”
On line 44, which is

local newCFrame =  CFrame.new(character.HumanoidRootPart.Position+offset)*rotation

I think you want this:

while true do
	wait()
	local newCFrame = CFrame.Angles(math.rad(45), 0, 0)
	local offset = Vector3.new(0,1,-5)
	clone.WoodDoor:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame*CFrame.new(offset)) 
	clone.WoodDoor:SetPrimaryPartCFrame(clone.WoodDoor:GetPrimaryPartCFrame() * newCFrame)

end

Instead of:

You’ll have to make sure you have the base cframe times the newcframe, Example:

   clone.WoodDoor:SetPrimaryPartCFrame(baseCFrame*newCFrame)

baseCFrame would be the door’s primary part