can’t seem to find this anywhere, so i’ll post it here
so I am having trouble with spawning a part above another part when the original part is at an angle. I want it to look like this:
But it ends up putting the part at the correct angle, just not parallel.
I’ve tried doing this:
local orientation = player.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("AlignOrientation")
if orientation then
orientation:Destroy()
end
local part = Instance.new("Part")
part.CanCollide = false
part.Parent = workspace
part.Size = Vector3.new(1,1,1)
part.Anchored = true
part.Name = "Midpoint of ".. CurrentPart.Name
local x = math.cos(CurrentPart.Orientation.Y) * 4
local z = math.sin(CurrentPart.Orientation.Y) * 4
part.CFrame = CFrame.new(CurrentPart.Position + Vector3.new(x,4,z)) * CFrame.Angles(math.rad(CurrentPart.Orientation.X),math.rad(CurrentPart.Orientation.Y),math.rad(CurrentPart.Orientation.Z))
--player.Character:PivotTo(CFrame.lookAt(player.Character.PrimaryPart.Position, CurrentPart.Position + Vector3.new(0,4,0)) * CFrame.Angles(math.rad(CurrentPart.Orientation.X),math.rad(CurrentPart.Orientation.Y),math.rad(CurrentPart.Orientation.Z)))
player.Character:PivotTo(CFrame.lookAt(player.Character.PrimaryPart.Position, part.Position))
orientation = Instance.new("AlignOrientation")
orientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
orientation.Parent = player.Character:FindFirstChild("HumanoidRootPart")
orientation.RigidityEnabled = true
orientation.Attachment0 = player.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("AlignAttach")
orientation.CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame
I can’t seem to find a way to do this, since i keep getting errors like “CFrame Expected, got Vector3” and “Vector3 expected, got CFrame”.
I’m sure the answer is (relatively) simple, but I can’t seem to figure it out
help would be appreciated