Need help with rotating a part from a certain pivot point

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a tree generator.

  2. What is the issue? Include screenshots / videos if possible!
    I’m having issues with rotating the branches.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked at other forum posts like this: Help with rotating on Pivot

local Thickness = 2
local Branches = 10
local Height = 8
local Log = script.Parent
local BranchPosition
local Clone

function Branch(BranchPosition)
	Thickness = Thickness - 0.2
	Height = Height - 1
	Clone = Log:Clone()
	Clone.Script:Destroy()
	Clone.Size = Vector3.new(Height,Thickness, Thickness)
	Clone.CFrame = CFrame.new(BranchPosition.X, BranchPosition.Y + Height/2, BranchPosition.Z)
	Clone.Orientation = Vector3.new(0,0,60)
	Clone.Parent = script.Parent.Parent
end

script.Parent.Size = Vector3.new(Height,Thickness, Thickness)
Log.Position = Vector3.new(Log.Position.X, Height/2 + 1, Log.Position.Z)
BranchPosition = Vector3.new(Log.Position.X, Height, Log.Position.Z)
Branch(BranchPosition)

In Studio, open “Pivot Editor” while selecting the branch and move the pivot to the end of the branch that is touching the tree. This alters the orientation the branch will rotate on.

1 Like

The pivot position is already at the end of the branch