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

How do I change a players orientation?

Asked by 6 years ago

I'm having trouble with this. What I want to do is make the player look towards something using XYZ coords. I've tried changing the torso's orientation using Vector3, but doesnt work because it kills the player when rotation happens. How do I do this?

1 answer

Log in to vote
1
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Well we can either use a bodymover, specifically bodygyro or setprimarycframe.

First let's set a position variable

local pos = Vector3.new(0,0,0)

this is where he will look at

When using a bodygyro we will create one, change its 'cframe' then place it inside the humanoidrootpart

local bg=Instance.new("BodyGyro")
bg.cframe=pos
bg.Parent=character.HumanoidRootPart

Bodygyro final:

local pos = Vector3.new(0,0,0)

local bg=Instance.new("BodyGyro")
bg.cframe=CFrame.new(pos)
bg.Parent=character.HumanoidRootPart

For setprimarycframe, we will use the function :SetPrimaryPartCFrame() to make the humanoidrootpart look in a certain direction, in this case towards the position

character:SetPrimaryPartCFrame(CFrame.new(character.HumanoidRootPart.Position,pos))

Final setprimarycframe

local pos = Vector3.new(0,0,0)

character:SetPrimaryPartCFrame(CFrame.new(character.HumanoidRootPart.Position, pos))

I did not set a character variable for both examples.

0
I'll try it later. I'm doing something else. Thanks for the help by the way flufffybuns 89 — 6y
0
Thanks! This works great. I'll remember this for the future. flufffybuns 89 — 6y
Ad

Answer this question