Motor6D CurrentAngle recreation using Transform

I’m trying to recreate Motor6D’s behaviour with DesiredAngle through Transform. I have no clue, however, how I’d be able to recreate it faithfully. I’ve nearly got it, but not quite…

I have a function which will look for the passed motor in a Velocities, DesiredAngles and CurrentAngles table and get the data for it from those tables, and then apply it to the Transform. The CurrentAngles, Velocities and DesiredAngles tables take the place of the CurrentAngle, MaxVelocity and DesiredAngle properties on a Motor6D.

On heartbeat, I call this function 4 times, once for the shoulder and hip motors.

	local function mathlol(motor,dt)
		if(not desiredAngles[motor])then
			desiredAngles[motor]=0;
		end
		if(not velocities[motor])then
			velocities[motor]=.1;
		end
		if(not currentAngles[motor])then
			currentAngles[motor]=0
		else
			if(currentAngles[motor]<desiredAngles[motor])then currentAngles[motor]=currentAngles[motor]+(velocities[motor]) end
			if(currentAngles[motor]>desiredAngles[motor])then currentAngles[motor]=currentAngles[motor]-(velocities[motor]) end
			motor.Transform=CFrame.Angles(0,0,currentAngles[motor])
		end
	end
-- in the heartbeat
		mathlol(RightShoulder,dt) -- RightShoulder is Torso['Right Shoulder']
		mathlol(LeftShoulder,dt) -- Torso['Left Shoulder']
		mathlol(RightHip,dt) 
		mathlol(LeftHip,dt)

My code looks a lil bit like this so far. It’s not perfect, but my math for calculating the CurrentAngle is wrong. I was wondering if anybody had any insight into how I could faithfully recreate how CurrentAngle and DesiredAngle works for motors, without using those properties?
If you need me to elaborate or explain further, I’ll be happy to provide details