Trouble Calculating a Rotational Velocity

I am currently having trouble calculating some sort of rotational velocity

So I am trying to make a system for a gun tool to wiggle on your back with rotation (of the Y axis) of the part its welded to (usually the torso) and the actual jiggling mechanic is working fine thus far. My problem is that I’m having trouble finding some sort of rotational velocity to set off the jiggle/sway direction and magnitude.

In a simplified way when I turn right I want the gun to sway left and when I turn left I want the gun to sway right

I cannot use the .RotationalVelocity property because even when called from the client it does not account for animations or client movement which is crucial for the swaying.

I tried another system where I subtract the current rotation from the rotation from the last frame to get directional difference of the angle for that frame however roblox’s rotation property is weird and is calculated -180 to 180 instead of on a 360 basis. This makes the direction constantly switch the way it sways which is not good.

I’ve been told many times about adding or “moding” it to be on a 360 basis but that’s not exactly the problem. Roblox tries to get the smallest rotation possible for the property I suppose, for instance, when I rotate right it will go down from 0 to -90, however, when it reaches -90 it will began going back up on a scale to 0 as I keep turning right.

There isn’t much code to show really, I simply am using a spring module to set off sway, I need some sort of Vector3 velocity that supplies how much and what direction the Torso is rotating.

Videos
This is using my angular difference from the last frame system, this is what I want it to look like all the way around (360 degrees): https://i.gyazo.com/3e444850ac21cfa77d47be79a5a43977.mp4

This is what it actually looks like all the way around:
Output:
LastRot is the last frames rotation
CurrentRot is the current rotation
Difference is the calculated difference I got
https://i.gyazo.com/cde1f624ebaa5c094636bcf604a0eb66.mp4

The sway keeps changing direction because of the way roblox displays rotation, I can’t figure out how to get a consistent difference with the math

For calculations as I said I tried multiple methods but the calculation in these videos is simply
local RotationalVelocity = LastRotation-CurrentRotation

If you have any ideas on how I can get the torso rotational velocity which includes client animations please let me know it would be much appreciated

I think I understand, but could you send a video? I just want to make sure I understand the problem correctly.

Sure thing.

This is using my angular difference from the last frame system, this is what I want it to look like all the way around: https://i.gyazo.com/3e444850ac21cfa77d47be79a5a43977.mp4

This is what it does look like all the way around:
LastRot is the last frames rotation
CurrentRot is the current rotation
Difference is the calculated difference I got
https://i.gyazo.com/cde1f624ebaa5c094636bcf604a0eb66.mp4

The sway keeps changing direction because of the way roblox displays rotation, I can’t figure out how to get a consistent difference with the math

For calculations as I said I tried multiple methods but as of these videos the calculation is simply
local RotationalVelocity = LastRotation-CurrentRotation

I suppose you didn’t find anything

Actually I did try for a couple of hours, but I couldn’t find a solid solution. Sorry :frowning:

It’s kinda late to ask, but can you explain how did you made that script? Its kinda hard for me to understand spring modules, will be very thankful