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

How to change HumanoidRootPart's Orientation without breaking the character?

Asked by
aiuis 85
6 years ago
Edited 6 years ago

Argument is mouse

Player.Character.HumanoidRootPart.CFrame=Player.Character.HumanoidRootPart.CFrame*CFrame.Angles(0,Argument.Y,0)

I tried making a script where when you mouseclick your character turns to the Y position of your mouse. But I end up with a broken character. I really need your help pls

1 answer

Log in to vote
0
Answered by 6 years ago

You are trying to place a 2-Dimensional value (Mouse.X) inside a 3-Dimensional one (CFrame). Mouse.X is basically the x coordinate of the 2-Dimensional screen, and so using that would not work for a 3-Dimensional position like CFrame. That said, you would want the HumanoidRootPart's CFrame to be the X value of the mouse's Hit property, which is basically the CFrame value of where the mouse is pointing:

--Assume hrp is the HumanoidRootPart you are trying to use
hrp.CFrame=CFrame.new(hrp.Position)*CFrame.Angles(0,Argument.Hit.x,0)

Please accept answer if this helped :)

0
Thanks for the explanation aiuis 85 — 6y
Ad

Answer this question