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.
How do I get the tower to stand up and still rotate with its target?