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

How Do I Rotate A Character Without A Turning Movement?

Asked by 7 years ago
Edited 7 years ago

Hello, I'm a bit new to scripting and I only know the basics. So basically, I'm making a 2D and I want it so when you press A you look to the left instantly, if you press D you you look to the right instantly, and when you press W, you look away from the camera instantly. I've already disabled AutoRotate, so my character doesn't rotate around anymore, but I still want it to face the direction I'm moving, can anyone help me with this? Thank you.

 local plyr = game.Players.LocalPlayer
plyr.Character.Humanoid.AutoRotate = false

1 answer

Log in to vote
1
Answered by 7 years ago

What you should use is a BodyMover. What BodyMovers do is pushing, pulling, rotating, etc. parts. The BodyMover you need is BodyGyro. What BodyGyro does is rotate the part to what you choose.

local BodyGyro = Instance.new('BodyGyro', player.HumanoidRootPart) 
-- Every BodyMover has 'P' and 'D' properties. 
BodyGyro.P = 10000 -- This is how quick the part would rotate.
BodyGyro.D = 1000 -- This is how fast the part would stop.
BodyGyro.CFrame = CFrame.new(0,-90,0) -- This would point the character away from the camera if the default direction is 0, 0, 0
BodyGyro.CFrame = CFrame.new(0,90,0) -- This would point the character towards the camera.

BodyGyro in Roblox Wiki: http://wiki.roblox.com/index.php?title=API:Class/BodyGyro

Ad

Answer this question