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

How would I make a part face the same direction as the character?

So, I have created a pet that follows the character around. I want it, however, to face the same direction that the character is facing at all times (so you can see the face of the pet). I believe this will involve changing the x-axis of the orientation of the pet to the that of the character's HumanoidRootPart or changing the x-axis of the orientation of the pet to the character's HumanoidRootPart's lookVector. I am unsure how to do this and have tried asking on the Discord, but to avail. Here is the code I am currently using in a Script to move the pet to near the character's head:

while true do
	wait()
	bodyPosition.Position = character.Head.CFrame:pointToWorldSpace(Vector3.new(2.5, 1.5, 0))
end

bodyPosition is a BodyPosition inside of the pet. Please help, thanks!

1 answer

✓ Accepted answer

Hello,

while true do wait()
    pet.Head.CFrame = CFrame.new(part.Head.CFrame.p, part.Head.CFrame.p + Character.HumanoidRootPart.CFrame.lookVector)
end

Hope this helps you!

Please upvote if it did.

4 comments

0

use a while true do loop

0

Works! Thanks so much, once again!

0

I was testing this out in game, and it's extremely glitchy and buggy. Works fine in studio though.

0

Finally got this working by using a BodyGyro. Oof.

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