Ok so I'm making a script where "A" rotates the character counter-clockwise and "D" clockwise, but there is a bug causes the player to wiggle extremely quickly.
local turnSpeed = 7.5 USI.InputBegan:connect(function(inputObject) if player.Character then while inputObject.KeyCode == Enum.KeyCode.A do root.CFrame = root.CFrame*CFrame.Angles(math.rad(0), math.rad(turnSpeed), math.rad(0)) wait() end while inputObject.KeyCode == Enum.KeyCode.D do root.CFrame = root.CFrame*CFrame.Angles(math.rad(0), math.rad(-turnSpeed), math.rad(0)) wait() end end end) USI.InputEnded:connect(function(inputObject) if player.Character then while inputObject.KeyCode == Enum.KeyCode.A do root.CFrame = root.CFrame*CFrame.Angles(math.rad(0), math.rad(-turnSpeed), math.rad(0)) wait() end while inputObject.KeyCode == Enum.KeyCode.D do root.CFrame = root.CFrame*CFrame.Angles(math.rad(0), math.rad(turnSpeed), math.rad(0)) wait() end end end)
Sometimes the person isn't wiggiling other times he goes really fast, and sometimes he moderitly. How can this be fixed?
Figured it out:
USI.InputBegan:connect(function(inputObject) if player.Character then if inputObject.KeyCode == Enum.KeyCode.A then turnSpeed = turnSpeed + 7.5 end if inputObject.KeyCode == Enum.KeyCode.D then turnSpeed = turnSpeed - 7.5 end end end) USI.InputEnded:connect(function(inputObject) if player.Character then if inputObject.KeyCode == Enum.KeyCode.A then turnSpeed = turnSpeed - 7.5 end if inputObject.KeyCode == Enum.KeyCode.D then turnSpeed = turnSpeed + 7.5 end end end) while character do root.CFrame = root.CFrame*CFrame.Angles(math.rad(0), math.rad(turnSpeed), math.rad(0)) wait() end
I figured out that problem was that multipul anlges were being set but not all at the same time, causing the character to wiggle. So I made it where only one angle was changed for the whole script rather than the whole time.