Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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.

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)
0
What script you use and where did you put it? HeyItzDanniee 252 — 6y
1
LocalScript and in StarterPack kaspar1230 345 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

If you want it to be instant there is no need to use a body gyro, you can change it instantly using CFrame or (I would not suggest this) Orientation.

You can find out more about CFrame here:

http://wiki.roblox.com/index.php?title=CFrame

Ad

Answer this question