Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change a players orientation?

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

✓ Accepted answer

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.

2 comments

0

I'll try it later. I'm doing something else. Thanks for the help by the way

0

Thanks! This works great. I'll remember this for the future.

This discussion is preserved as it was. New answers, comments, and votes are closed.