Rotating Entire Part Cleanly

Hello,
I’m a new scripter and I’m trying to figure out how I can cleanly orient an entire model to a specific direction.
I tried this script and it does orient it the way I want but it doesn’t rotate the entire model with everything remaining in the correct position, instead it just rotates each individual part
What should I do instead? I tried getpivot but it said tried to return nil value.

local model = script.Parent:WaitForChild("CharacterParts"):GetChildren()
local angle = CFrame.Angles(0,math.rad(90),0)
local function orient(part)
	part.CFrame= CFrame.new(part.Position) * angle
end
for i,v in ipairs(model) do
	if v:IsA("BasePart") then
		orient(v)
	end
end

Any help is appreciated

AlignOrientation or you can use linear interpolation (lerping)

local modelCFrame = model:GetBoundingBox()

model:PivotTo(modelCFrame * CFrame.Angles(0, math.rad(90), 0)

this rotates it right or left by that amount, it doesn’t set it to the orientation specified

Oh, mb.
I just copied what I had which was meant to add.

This should work, hopefully.

model:PivotTo(CFrame.new(modelCFrame.Position) * CFrame.Angles(0, math.rad(90), 0))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.