BodyGyro How Turn Left, Right Instantly On Key Press?
Asked by
6 years ago Edited 6 years ago
I'm trying to turn the character left instantly when pressed A and turned right instantly when pressed D. Everything except the turning left or right works. It does print out debug when keys pressed.
01 | local plr = game:GetService( "Players" ).LocalPlayer |
02 | local char = plr.Character or plr.CharacterAdded:Wait() |
03 | local rootpart = char:WaitForChild( 'HumanoidRootPart' ) |
04 | local humanoid = game:GetService( "Players" ).LocalPlayer.Character.Humanoid |
05 | humanoid.AutoRotate = false |
08 | BodyGyro = Instance.new( 'BodyGyro' ) |
09 | BodyGyro.Name = 'Turning' |
10 | BodyGyro.Parent = rootpart |
14 | game:GetService( "UserInputService" ).InputBegan:connect( function (input) |
15 | if input.KeyCode = = Enum.KeyCode.D then |
17 | BodyGyro.CFrame = CFrame.new( 0 ,- 90 , 0 ) |
21 | game:GetService( "UserInputService" ).InputBegan:connect( function (input) |
22 | if input.KeyCode = = Enum.KeyCode.A then |
24 | BodyGyro.CFrame = CFrame.new( 0 , 90 , 0 ) |