Help with using script to rotate an imported mesh around a custom pivot point

I’m new to scripting (more of a builder) so please go easy on me.

I want to rotate a mesh using CFrame but its off centered somehow. I imported it from blender and on blender, the mesh was centered to the 3D cursor like this:

But when rotated using CFrame, it isn’t centered:
https://gyazo.com/c2989a396e39f62770eef00f65b0a812

This is the code I use to rotate it.

local fan = script.Parent.fan

while wait() do
	fan.CFrame = fan.CFrame*CFrame.Angles(0, .05, 0)
end

How do I create a custom pivot point using CFrame to center the mesh? Google points me to setPrimaryPartCFrame but I’m not sure how or where to code it in. I’ve tried remodelling the mesh but it’s always off centered on studio.

1 Like

Add an attachment in the direct middle then use that as your pivot point.

How do I do that? I’ve inserted the attachment and positioned it to the center. What’s next?

Bump because I still can’t find a solution. (Hope it’s allowed)

Kinda a complicated response and probably a better way but I made a part and made it a anchor. Even scales to size.

local Fan = script.Parent
local RunService = game:GetService("RunService")
local FanOrientation = Fan.Orientation

local Anchor = Instance.new("Part")
Anchor.Name = "Anchor"
Anchor.Anchored = true
Anchor.CanCollide = false
Anchor.Size = Vector3.new(0.01, 0.01, 0.01)
Anchor.Position = Fan.Position
Anchor.Color = Color3.fromRGB(255, 0, 0)
Anchor.Transparency = 1
Anchor.Parent = game.Workspace
Anchor.Orientation = FanOrientation

local Weld = Instance.new("Weld")
Weld.Part0 = Anchor
Weld.Part1 = Fan
Weld.C0 = CFrame.new(Fan.Size.X / (-0.25 * 185), 0, Fan.Size.Z / (-0.4 * 65))
Weld.Parent = Anchor


RunService.Stepped:Connect(function()
	Anchor.CFrame = Anchor.CFrame * CFrame.Angles(0, .05, 0)
	wait()
end)
1 Like

Thanks so much! You helped me a ton.