So when the target moves further and further away, the FirePoint no longer aligns the orientation at the target.
Code:
local function AimAtTarget()
if target and target.PrimaryPart then
local currentCFrame = HumanoidRootPart.CFrame
local targetPosition = target.PrimaryPart.Position
local lookVector = (targetPosition - FirePoint.Position).Unit
local newCFrame = currentCFrame:Lerp(CFrame.new(HumanoidRootPart.Position, HumanoidRootPart.Position + lookVector * Vector3.new(1, 0, 1)), 0.1)
HumanoidRootPart.CFrame = newCFrame
end
end
RunService.Heartbeat:Connect(function()
AimAtTarget()
end)