Motor6d spinning help

Hi everyone. I have no experience with Motor6d as I usually use a hinge or tween to move something. But I am trying to figure out how I would make a wheel spin using a Motor6d with the speed being controlled by a value like if the value is zero it wouldn’t spin or if it’s 20 it would go fast. I’ve heard that you use cframe but there’s nothing on here that covers this.
Thank you
-coleballer007

I know that by making the wheel a humanoid rig, you can use an animation to make the wheel spin. You can control animation speed with numbers easily, but I don’t really know if this is what you wanted though.

You can just use a script to constantly change DesiredAngle, and use a value to manipulate speed:

local SpeedValue = script.SpeedValue --Or wherever you want the SpeedValue to be located.
local Motor = workspace.Car.Wheel.Motor6D --Or wherever the Motor6D is.
local DesiredAngleChange = 0 --Based on speed.
--Find the radius of the wheel, and input it where the "r" is.
local v = workspace.Car.Wheel.Magnitude
local Math = r*v/r*r

DesiredAngleChange = Math
--This cannot calculate speed because I am not sure how to get speed out of angular velocity of a wheel.

while true do
	Motor.DesiredAngle = Motor.DesiredAngle + DesiredAngleChange
	game:GetService("RunService").Heartbeat:wait()
end

I don’t believe that a Motor6D works that way too well. If the motor spins for a long enough time just adding the added angle would create issues. Motor6Ds have a MaxVelocity value that changes their speed. I’m pretty sure there’s been other posts on how to rotate a Motor6D in a complete circle though since they typically work from 180 to -180 degrees (actually, in radians).

@coleballer007 why not use a HingeConstraint. It has an AngularVelocity when its set to Motor so all you have to do is update that value.

No, DesiredAngleChange is stored locally in the script, and is only used for the DesiredAngle change increment in the loop.

It is not actually a property though.

Hinges cause lag and there would be a lot of spinning stuff so it would cause sever lag

Is it a vehicle wheel, or a spinning platform?
I just wondered since it depends on what the purpose is in case you need actual physics to be involved.

Just on a platform. No physics needed

Jus to ask if players have to walk on the platform? If so that’s going to be an issue since player movement on moving/spinning platforms is controlled by physics.

They won’t have to walk on it it’s just for show

1 Like