Align orientation only works in studio

Hi, for my game I am using align orientation to turn an NPC. But it only works in studio and not in real game.
Network Owner is also set to nil
Edit: Seems to be a roblox bug as it is happening to other users

2 Likes

I am also having this exact issue, and It seems a temporary workaround is to disable the AlignOrientation, set the cframe, and then reenable it. If I had to guess, setting the CFrame is no longer updating the constraint, since attaching parts to the main part seems to also make it update to a lesser degree.

1 Like

As with all scripting support questions, we can’t do much without seeing your script.

Sorry, I didn’t put a script because I thought it might be something else.

connection = RunService.Heartbeat:Connect(function()
	if self._running then
		if waypointIndex <= #waypoints then
			if self.Npc.PrimaryPart.AlignOrientation.Enabled ~= true then
				self.Npc.PrimaryPart.AlignOrientation.Enabled = true
			end
			if self.Npc.PrimaryPart.AlignPosition.Enabled ~= true then
				self.Npc.PrimaryPart.AlignPosition.Enabled = true
			end
			if getNextPosition then
				local raycastParams = RaycastParams.new()
				raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
				raycastParams.FilterDescendantsInstances = {game.Workspace.Map}
				local raycastResult = workspace:Raycast(waypoints[waypointIndex].Position + Vector3.new(0,5,0),Vector3.new(0,-10,0),raycastParams)
				if raycastResult then
					if not previousRaycastResult then
						previousRaycastResult = raycastResult
					end
					if raycastResult.Instance.ClassName == "WedgePart" or previousRaycastResult.Instance.ClassName == "WedgePart" then
						if previousRaycastResult.Instance.ClassName == "WedgePart" and raycastResult.Instance.ClassName ~= "WedgePart" then
							self.Npc.PrimaryPart.AlignPosition.Position = raycastResult.Position + Vector3.new(0,1)
							self.Npc.PrimaryPart.AlignOrientation.CFrame = CFrame.lookAt(self.Npc.PrimaryPart.Attachment.WorldPosition,raycastResult.Position + Vector3.new(0,1))
						else
							self.Npc.PrimaryPart.AlignPosition.Position = raycastResult.Position + Vector3.new(0,.5)
							self.Npc.PrimaryPart.AlignOrientation.CFrame = CFrame.lookAt(self.Npc.PrimaryPart.Attachment.WorldPosition,raycastResult.Position)
						end
						
						getNextPosition = false
					else
						self.Npc.PrimaryPart.AlignPosition.Position = raycastResult.Position
						self.Npc.PrimaryPart.AlignOrientation.CFrame = CFrame.lookAt(self.Npc.PrimaryPart.Position,Vector3.new(raycastResult.Position.X,self.Npc.PrimaryPart.Position.Y,raycastResult.Position.Z))
						getNextPosition = false
					end
					previousRaycastResult = raycastResult
				else
					self.Npc.PrimaryPart.AlignPosition.Position = waypoints[waypointIndex].Position
				end
			end
			
			if (self.Npc.PrimaryPart.Attachment.WorldPosition - self.Npc.PrimaryPart.AlignPosition.Position).Magnitude < 1.5 then
				waypointIndex += 1
				getNextPosition = true
			end
		else
			connection:Disconnect()
		end
	else
		connection:Disconnect()
	end
end)

Would it have anything to do with this from the AlignOrientation page?:

Note

Any torque created by AlignOrientation will be applied about the center of mass of the parent of the attachments (or the center of mass of parts rigidly connected to the parents). Also note that if this constraint attaches one part ( A ) to another part ( B ) that is anchored or connected to an anchored part ( Z ), part A will not be locally simulated when interacting with a player.

1 Like

Hey sorry for the late reply it was a Roblox bug but they fixed it lol