Basically I am making a rotor, you press the button and a motor object makes the rotor head rotate in the left or right direction. I would like for the motor to rotate continuously, but after a while it stops.
local base=script.Parent local spinny = script.Parent.Parent.Spinny local speed=(((math.pi*2)/60)/2) local bl= script.Parent.Parent.ButtonLeft local br=script.Parent.Parent.ButtonRight local right=false local left=false local runningc=script.Parent.Parent.Running local offc=script.Parent.Parent.Off local motor=Instance.new("Motor", base) motor.Part0=base motor.Part1=spinny motor.MaxVelocity=speed motor.C0=CFrame.new(0, 0, -2.5) -- -z -x, -y bl.ClickDetector.MouseClick:connect(function() if left==false then left=true right=false bl.BrickColor= runningc.Value br.BrickColor= offc.Value elseif left==true then left=false right=false bl.BrickColor=offc.Value br.BrickColor=offc.Value end end) br.ClickDetector.MouseClick:connect(function() if right==false then right=true left=false br.BrickColor= runningc.Value bl.BrickColor= offc.Value elseif right==true then left=false right=false bl.BrickColor=offc.Value br.BrickColor=offc.Value end end) while true do wait() if left==true then motor.DesiredAngle=motor.CurrentAngle + math.rad(10) elseif right==true then motor.DesiredAngle=motor.CurrentAngle - math.rad(10) else motor.DesiredAngle=motor.CurrentAngle end end
Thanks for any help.
Though I am not the best scripter, I can guide you here. First you must have 2 different variables that are equal to 0 Ex:
local StopSpinning = 0 local Rotate = 0
Note:*Or you can just use i = 0
for StopSpinning *
Next you must have a repeat loop like sammiya suggested.
( X = your item you want to spin)
repeat X.Rotation = Vector3.new( 0, 0, 0)--Change the axis you want it to spin on to your "Rotate" variable. wait(.01) Rotate = Rotate + 3 until StopSpinning == 1
Rotation directions: In X spot: Like a rolling wheel In Y spot: Like a top or a jack In Z spot: Flips like a coin in the air or you can make put Rotate in several directions to make it unique. You can set the off button to make StopSpinning (or i) to 1.
If you have more than 1 loop, it will not work unless you use Coroutine Ex:
local TheRotateLoop = coroutine.wrap(function() repeat coin.Rotation = Vector3.new( 0, 0, a) wait(.01) a = a+3 until staph == 1 end) local TheSecondLoop = coroutine.wrap(function() --Stuff end) TheRotateLoop() TheSecondLoop()
You can add more loops by copying a loop and and putting it at the bottom so it runs like the others.
Hope it works, if it does, please feel free to ask questions if you have them and upvote ;3