Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

BodyGyro How Turn Left, Right Instantly On Key Press?

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.

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local rootpart = char:WaitForChild('HumanoidRootPart')
local humanoid = game:GetService("Players").LocalPlayer.Character.Humanoid
	humanoid.AutoRotate = false


	BodyGyro = Instance.new('BodyGyro') 
	BodyGyro.Name = 'Turning'
	BodyGyro.Parent = rootpart
	BodyGyro.P = 10000 
	BodyGyro.D = 1000

game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.D then
	print "debug"
       BodyGyro.CFrame = CFrame.new(0,-90,0)
    end
end)

game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.A then
	print "debug"
       BodyGyro.CFrame = CFrame.new(0,90,0)
    end
end)

2 comments

0

What script you use and where did you put it?

1

LocalScript and in StarterPack

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.