How can I align a Player towards another Player?

I tried using the code below but it kept on doing this:

  PlayersHRP.CFrame =, TargetsHRP.Position)
  --PlayersHRP is the Player's humanoid root part, TargetsHRP is the humanoid root part that the player is trying to align its Y axis to.

The goal is to align the players towards the another player while also allowing them to move freely(while still keeping them faced towards the other player). All answers are appreciated.

You could try a BodyGyro or AlignPosition. I wanna say that a lot of HumanoidRootPart CFraming gets overwritten by the player’s Control Script unless bound to RenderStepped.

I should mention that even with a physics mover, though, that players in first-person will still always face the direction of the camera unless a bigger work-around is used.

1 Like

How would I be able to use BodyGyro to achieve my goal?

Did you add this in a loop or RenderStepped.

I still wan’t the player to be able to move while facing the opposing player. The player won’t be able to move if I use a loop/RenderStepped.

Try this

-- BodyGyro should be inside PlayersHRP
BodyGyro.CFrame =, TargetsHRP.Position)
This is what happens if you put the code inside a loop.

also set it’s torque to to 0, 10000, 0
It works, but it doesn’t turn the player fast enough. Is there any way for it to snap to the player at a faster speed?

try increasing the torque so 0,30000,0 for example

1 Like

It still doesn’t turn fast enough or me. :frowning:

Make to torque higher until its fast enough.

If the assembly is moving too slowly, consider lowering the D (dampening) property. Also consider raising the MaxTorque and/or P (power) properties. According to this.
It works, but is this only way to achieve this effect, or are there more effective methods?

You could use AlignPosition.

Can you explain how would I could use AlignPosition to achieve my goal?

In this video, the pet moves with the same orientation and position(Reduced).

robloxapp-20200927-1236069.wmv (3.1 MB)

Here’s the example code for your goal:

        local attachment1 ="Attachment");
        attachment1.Parent = Character.HumanoidRootPart;
        attachment1.Position = Character.HumanoidRootPart.Position -, -2, -3)
        local attachment0 ="Attachment", workspace.Pet) -- I have a square named "Pet" in the workspace.
        local alignPosition ="AlignPosition", workspace)
        local alignOrientation ="AlignOrientation", workspace)
        alignOrientation.Attachment0 = attachment0 -- Attachment 0's orientation will be the same as attachment 1.
        alignOrientation.Attachment1 = attachment1
        alignOrientation.MaxTorque = 25000
        alignPosition.MaxForce = 25000
        alignPosition.Attachment0 = attachment0 -- Attachment 0's position is the attachment 1
        alignPosition.Attachment1 = attachment1

I hope that solves your problem

Check this out.

I’ll check that out right now, if it works better then the BodyGyro method, i’ll make this the new solution. :slight_smile:

1 Like