Getting 2 players to look at eachother has some weird behavior on the server

In the video below, you can see the issue:

On both clients (left), the behaviour is normal, and they face each other correctly.

But on the server, the characters do all sorts of crazy things.

The code responsible for doing this is inside a RenderStepped loop, and it rotates the player to face the opponent:

-- Inside a LocalScript
char.HumanoidRootPart.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position ,targetPos, Vector3.yAxis)

Removing this line fixes the problem, which is a decent hint to what causes this issue. Is there a better way to do this though? Because my serverside code is experiencing Heisenberg’s uncertainty principle when trying to find the position of the player :frowning:

2 Likes

This might work:

char.HumanoidRootPart.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position, Vector3.new(targetPos.X, char.HumanoidRootPart.Position.Y, targetPos.Z))
1 Like

Sorry, I forgot to clarify what targetPos was:

-- Inside a localScript
-- opp is the opponent's character
local targetPos = Vector3.new(opp.HumanoidRootPart.Position.X, char.HumanoidRootPart.Position.Y, opp.HumanoidRootPart.Position.Z)
char.HumanoidRootPart.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position ,targetPos, Vector3.yAxis)

try removing Vector3.yAxis ive seen scripts that have the same objective but enver have i seen that part

1 Like

Same result :frowning: . Idk why the server freaks out like this

Small update: The behavior is normal on other player’s screens too (Those who do not have the lookat code apply to them). This is (for some reason) a serveride issue only :confused:

it looks like there is more code responsible for positioning the players. when they get teleported away from the transparent parts. could i see that?

1 Like

Yep:

		opp1.HumanoidRootPart.Position += Vector3.new(0, 0, 100)
		opp2.HumanoidRootPart.Position += Vector3.new(0, 0, 100)

Let me try change this to Model:MoveTo() and ill update you

UPDATE: This is the fix! DO NOT SET THE HUMANOIDROOTPART POSITION MANUALLY

@Bikereh Thx. Ill add the solution to your post. If you can, pls update so its more clear to others.

-- Opp1 and opp2 are both characters
opp1:MoveTo(opp1.HumanoidRootPart.Position + Vector3.new(0, 0, 100))
opp2:MoveTo(opp2.HumanoidRootPart.Position + Vector3.new(0, 0, 100))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.