How to set AlignOrientation properly to look at Zombie

So what I am trying to do is to make Tower look at Zombie using AlignOrientation, however Tower goes crazy and does not look at Zombie properly.

image

So this is what I have so far. Tower has AlignOrientation in Torso, the Attachment0 is set to Node0 which is located in Torso, and Attachment1 is set to Node1 which is located in Terrain.

image

In the loop I set Node1 Orientation which is determinated by this:

Node1.WorldOrientation = Vector3.new(Target["Torso"].Position.X, Node1.WorldPosition.Y, Target["Torso"].Position.Z)

-- Target["Torso"] is Zombie's Torso
-- Node1 is the node which is attached to Terrain controlling the tower

AlignOrientation has these properties:

How I could make the Tower look at Zombie properly, using AlignOrientation?

Hey there,
I replicated what you intended to do in a baseplate with an R6 figure and an R15 player. See the code below.

Workspace Script

local Node1 = workspace.Terrain.Node1
local Target = workspace.Dummy
while true do
wait()
Node1.WorldOrientation = Vector3.new(Target["Torso"].Position.X+180, Node1.WorldPosition.Y, Target["Torso"].Position.Z+180) -- Add 180 so the zombie orientation flips so the player aligns properly
end

Client Script

wait(5) -- To yield and to test

local AO = Instance.new("AlignOrientation")
local Node0 = Instance.new("Attachment")
Node0.Parent = game.Players.LocalPlayer.Character.UpperTorso -- Change to Torso for R6
AO.Parent = game.Players.LocalPlayer.Character.UpperTorso -- Change to Torso for R6

AO.Attachment0 = Node0
AO.Attachment1 = workspace.Terrain.Node1

In general, doing an infinite while loop is bad practice, I just did it here for your concept. But the best way would be to check if the zombie moves in the world orientation and then run it. This code is not code you would want in your game as it is definitely not the most efficient, but it should help with getting down a solid way of using align orientation.

image
It seems it did nothing much

If it is facing the wrong direction then add 180 to the worldorientation x and z. Align orientation makes the parts fact the same direction. So if the zombie faces the player, the player would face away. That’s why you need the 180.

I did that, it goes crazy. Adding 180 is not a solution.

It worked for me. Did you modify any of the align orientation forces or values?

No. Tower is facing flat on ground sometimes