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

How do I set the rotation of the player?

Asked by 5 years ago
Edited 5 years ago

Not rotate the player (adding rotation) but actually setting the rotation to something (like setting it to 0, 0, 0 would make it completely unrotated). Here is the function I made which doesn't seem to be working too well.

function module.SetPlayerRotation(player, rotation)
    player:SetPrimaryPartCFrame(CFrame.new(player.HumanoidRootPart.Position, Vector3.new(math.rad(rotation.x), math.rad(rotation.y), math.rad(rotation.z))));
end 

EDIT: What I'm trying to do here is set the CFrame of HumanoidRootPart to a new CFrame equal to the current CFrame position, and a new given rotation. The function takes in an argument of a player to change the rotation of, and a rotation to set the player to.

0
instead of "player" you should be doing "player.Character" DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by
Vmena 87
5 years ago

There are many types of CFrame values you can set, you can see them all here: http://wiki.roblox.com/index.php?title=CFrame

CFrames are fairly complex, so for what you are doing you could always make a BodyGyro and change the orientation of the player with that. BodyGyro is an object and can be created with the Instance.new() function.

0
If you still want to use CFrame, you would probably use CFrame.Angles() Vmena 87 — 5y
0
not useful and not what he's looking for DeceptiveCaster 3761 — 5y
Ad

Answer this question