AlignOrientation Server Breaking Mysteriously Despite Same Code as Client

I’m working on a script to move an NPC ship, which is based on a root part. All other parts are welded and massless. The client performs as expected, smoothly turning the root when the A and D keys are pressed. The server, using the exact same root, exact same module function, and given network ownership, does not.

No matter the angle, the root does not turn for the server. Just as the client does, the server changes the properties of the AlignOrientation. However, it does not turn, no matter what. Using an AlignPosition in the same module function, the ship can move smoothly forward on server or client, proving that it is not a higher issue, it is directly related to the AlignOrientation.

Following is the relevant code from the loop, part of the module function which is called each frame:

local yPerFrame = (stat.Agility.Value * 10) * delta * 100 -- the 100 is to ensure that the cause isnt too small a degree, but the client works just fine without the 100, and it doenst fix the server
local turn = 0
if aDown then
	turn = turn + yPerFrame
end
if dDown then
	turn = turn - yPerFrame
end
print("Y change this frame is", math.round(turn * 1000) / 1000) -- this value does change as it should, and is the same as the client
root.TurnForce.Enabled = true
root.TurnForce.CFrame = CFrame.new(root.Position) * CFrame.fromEulerAnglesXYZ(0, math.rad(root.Orientation.Y + turn), 0)
	
local x, y, z = root.TurnForce.CFrame:ToOrientation()
local orient = Vector3.new(math.deg(x), math.deg(y), math.deg(z))
print("TURN ORIENT IS", orient) -- changes as it should, the root's current angle plus the y change this frame

The root object in question (rbxm)

I’ve been trying to fix this for days, please help.

The un-editable Active property of the AlignOrientation is false on the server, unlike on the client. But, I have no idea why. It should be the exact same as the client.

I found the issue. While this remains completely unexplained by the docs, I have determined that being owned by a client - even just automatically for a moment, before being given explicitly to the server - completely breaks the AlignOrientation. It must be created after the root is given to the server.

TL;DR Create your AlignOrientations after giving explicit ownership to the server, or your constraint will brick itself.

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