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

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

Asked by
lunatic5 409 Moderation Voter
5 years ago
Edited 4 years ago

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

Log in to vote
2
Answered by
arshad145 392 Moderation Voter
5 years ago
Edited 5 years ago

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.

0
use a while true do loop User#23365 30 — 5y
0
Works! Thanks so much, once again! lunatic5 409 — 5y
0
I was testing this out in game, and it's extremely glitchy and buggy. Works fine in studio though. lunatic5 409 — 5y
0
Finally got this working by using a BodyGyro. Oof. lunatic5 409 — 5y
Ad

Answer this question