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

How to make the player face an object?

I want to make the player forcefully face an NPC. What would I use in a script to pull this off?

3 comments

0

You can do this by ajusting the CFrame of the HumanoidRootPart to the NPC's lookVector I think?

0

We can adjust the HumanoidRootPart's CFrame lookAt to the HumanoidRootPart of the NPC, or we can also use BodyGyros.

0

So I was right? I just guessed::P

1 answer

✓ Accepted answer

One of the CFrame constructors is CFrame.new(Vector3 pos, Vector3 lookAt) which constructs a CFrame at position pos oriented towards lookAt.

character:SetPrimaryPartCFrame(CFrame.new(character.PrimaryPart.Position, NPC.PrimaryPart.Position))

Since most likely you don't want the player to teleport elsewhere I keep the position the same. It just looks at the NPC now.


####Don't forget to accept if this helps

1 comment

0

Thanks! This worked perfectly.

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