script.Parent.Humanoid.StateChanged:connect(function(state) if state == Enum.HumanoidStateType.Running then for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle +0.05 leftarm.DesiredAngle = rightarm.DesiredAngle -0.05 rightleg.DesiredAngle = rightarm.DesiredAngle +0.05 leftleg.DesiredAngle = rightarm.DesiredAngle -0.05 end wait(0.02) for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle -0.05 leftarm.DesiredAngle = rightarm.DesiredAngle +0.05 rightleg.DesiredAngle = rightarm.DesiredAngle -0.05 leftleg.DesiredAngle = rightarm.DesiredAngle +0.05 end wait(0.02) for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle -0.05 leftarm.DesiredAngle = rightarm.DesiredAngle +0.05 rightleg.DesiredAngle = rightarm.DesiredAngle -0.05 leftleg.DesiredAngle = rightarm.DesiredAngle +0.05 end wait(0.02) for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle +0.05 leftarm.DesiredAngle = rightarm.DesiredAngle -0.05 rightleg.DesiredAngle = rightarm.DesiredAngle +0.05 leftleg.DesiredAngle = rightarm.DesiredAngle -0.05 end wait(0.02) end end)
I want to make it so that an NPC runs until the state has changed but this only makes it run once, how do I change it so that it runs until the state has changed?
--Er so I'm not sure about this and I'm at school so I cannot test it but if it doesn't work try giving me output local running = false coroutine.resume(coroutine.create(function() repeat wait(0.1) until running == true while running do for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle +0.05 leftarm.DesiredAngle = rightarm.DesiredAngle -0.05 rightleg.DesiredAngle = rightarm.DesiredAngle +0.05 leftleg.DesiredAngle = rightarm.DesiredAngle -0.05 end wait(0.02) for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle -0.05 leftarm.DesiredAngle = rightarm.DesiredAngle +0.05 rightleg.DesiredAngle = rightarm.DesiredAngle -0.05 leftleg.DesiredAngle = rightarm.DesiredAngle +0.05 end wait(0.02) for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle -0.05 leftarm.DesiredAngle = rightarm.DesiredAngle +0.05 rightleg.DesiredAngle = rightarm.DesiredAngle -0.05 leftleg.DesiredAngle = rightarm.DesiredAngle +0.05 end wait(0.02) for i = 1, 6 do wait(0.01) rightarm.DesiredAngle = rightarm.DesiredAngle +0.05 leftarm.DesiredAngle = rightarm.DesiredAngle -0.05 rightleg.DesiredAngle = rightarm.DesiredAngle +0.05 leftleg.DesiredAngle = rightarm.DesiredAngle -0.05 end wait(0.02) end end)) script.Parent.Humanoid.StateChanged:connect(function(state) if state == Enum.HumanoidStateType.Running then running = true else running = false end end)
If this doesn't work try to give output or fix up what I'm forgetting. I have no way of testing this as of now so tell me how it works out!