Part doesn't rotate as intended

Hey yea It’s me again

So i have a part that spins, its welded to a basepart with a weldconstraint, but there is an issue

The part is tilted, and when rotating it spins weirdly

How it’s supposed to spin
image

How it spins

Code:

local partRotation = part.Orientation.Y

while status do 
	
	partRotation += 3 
	
	
	
	part.Orientation = Vector3.new(part.Orientation.X, partRotation, part.Orientation.Z)
	
	task.wait(cooldown) 
end

I tried using CFrame.Angles(), it works but spinning it like that also rotates the welded basepart.

HELP

1 Like

Instead of changing the Orientation property, you should switch it for a rotation matrix (CFrame for short)

Here’s how you can manipulate a part’s CFrame:

-- variables
local part = script.Parent

local ROTATE_INCREMENT = math.rad(4)
local ROTATE_SPEED_MODIFIER = 1/60

-- functions
local function spin()
	part.CFrame *= CFrame.Angles(0, ROTATE_INCREMENT, 0)
end

while (true) do
	spin()
	
	task.wait(ROTATE_SPEED_MODIFIER)
end

The function spin() is responsible for actually rotating the part. It multiplies the current part’s CFrame by a new CFrame labelled CFrame.Angles(0, ROTATE_INCREMENT, 0).

The conditional loop underneath the function is what will actually invoke the spin() function every x seconds - in this case x being ROTATE_SPEED_MODIFIER (A variable seen at the top)

  • ROTATE_SPEED_MODIFIER - Is the speed at which the conditional loop iterates at.
  • ROTATE_INCREMENT - Is the amount the part will orientate by every time the function spin() is invoked.

Additionally, you said you’ve welded parts to the main part. Make sure to un-anchor the welded parts and set the variable part to the main part.

Hope this helps, good luck :slight_smile:

Thanks for the detailed explanation, so much info.

There’s one problem tho, the basepart must NOT rotate.

I’ll model it into a tool and that part will be the handle so that’s why I’d like it to not rotate.

1 Like

You’d like the main part to spin around a ‘Handle’ part which is inside of a Tool? I’m a little confused, could you elaborate further please?

The handle is the main part, the part i want to spin is the neon part u see in the video, which levitates and spins above the handle

1 Like

Ah, I see. Well I’m yet to learn about the Tool class and its entirety. I could suggest using an Animation for the spinning part, or even an AlignPosition mixed with an AlignOrientation :person_shrugging:.

Sorry I couldn’t help, I wish you the best of luck, hopefully somebody smarter than me can assist you. :slight_smile:

That’s okay, you still helped me alot, you taught me a couple things, thanks!

1 Like

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