Working on rotating hammer

I’ve been working on making a hammer that rotates using CFrame but I don’t know how to change the pivot of my rotation. I’ve tried looking at some videos but I couldn’t find any. The script does work but it’s not rotating in the pivot I want it to.

local Hammer = game.Workspace.Hammers:GetChildren()

while true do
	task.wait(0.1)
	for i,v in pairs(Hammer) do
		local HammerCFrame = v:GetPrimaryPartCFrame()
		v:SetPrimaryPartCFrame(HammerCFrame * CFrame.Angles(0,0,math.rad(10)))
	end
end

How do you want them to rotate?
You can change the pivot by changing which axis is math.rad(10)

v:SetPrimaryPartCFrame(HammerCFrame * CFrame.Angles(0,math.rad(10),0))

This will rotate the hammers on the Y axis.

I’m not trying to change the rotation, I’m trying to change the pivot so that it rotates differently.

What do you mean by differently?

You know how in builder f3x you can change your rotation to center, local, or last? Pivot is changing the point of rotation.

Just use :SetPivot.

Code:

local Hammer = game.Workspace.Hammers:GetChildren()

while true do
	task.wait(0.1)
	for i,v in Hammer do
		local HammerCFrame = v:GetPivot()
		v:PivotTo(HammerCFrame * CFrame.Angles(0, 0, math.rad(10)))
	end
end

I’m also really confused about what you mean by “rotates differently”.

1 Like

The output says SetPivot is not a valid member of Model “Workspace.Hammers.Hammer”

Oh, had to use PivotTo instead.

Where are you trying to set the pivot to?

To where you got the pivot, at v:GetPivot().

Sorry, I meant the pivot point. How do you want it to spin?

1 Like

well I already fixed it but if you wanna choose to how you wanna spin it you have to edit the pivot in the model tab on your part.

Sorry, I meant to write PivotTo.

If your problem is solved, mark your reply or my reply as the solution.

1 Like

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