I’m sorry if the answer seems obvious or anything, I just can’t find a way to fix this.
I’m trying to rotate a part whenever a player pressed the A or D keys using BodyAngularVelocity. It kind of works, but it’s super buggy.
Here is my script: (sorry if the code isn’t very good, I was just trying to throw together something quick)
workspace.CurrentCamera.CameraSubject = workspace.Car
workspace.Car.Name = game:GetService("Players").LocalPlayer.Name.." Car"
local uis = game:GetService("UserInputService")
local car = workspace:FindFirstChild(game:GetService("Players").LocalPlayer.Name.." Car")
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.D then
print("d")
car.right.MaxTorque = Vector3.new(4000,999999999999,4000)
elseif input.KeyCode == Enum.KeyCode.A then
print("a")
car.left.MaxTorque = Vector3.new(4000,999999999999,4000)
end
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.D then
print("d up")
car.right.MaxTorque = Vector3.new(0,0,0)
elseif input.KeyCode == Enum.KeyCode.A then
print("a up")
car.left.MaxTorque = Vector3.new(0,0,0)
end
end
end)
Whenever I press D to turn right, it either doesn’t move at all or hops a little right before just stopping again. For some reason, when I press A to turn left it never works at all.
Here is a video of me attempting to rotate it: (whenever my character moves right I’m pressing D, whenever my character moves left I’m pressing A, obviously)
So how can I (preferably) use BodyAngularVelocity to rotate the part without it acting buggy like this?