Targeting + Rotating Tower

I’m working on a tower defense game and currently scripting a tower to rotate towards its target

while true do 
	local target = FindNearestTarget()
	if target then
		local target_Pos = target.HumanoidRootPart.Position
		local tower_Pos = tower.Parent.PrimaryPart.Position
		local goal_CFrame = CFrame.new(tower_Pos, target_Pos)
		tower.Parent:PivotTo(goal_CFrame)
		
	end
	task.wait(.1)
end

This is the script that rotates based on the target.

It works, except the tower is sideways.
image

How do I get the tower to stand up and still rotate with its target?

It is probably something to do with its primary part if it has one. Make sure that it’s primary part is oriented correctly so that when it faces it, it is upright. If you don’t have one you can set one. If not, tell me that and I will do some more experimenting.

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