How can I move something behind a part, regardless of orientation?

In my game, I have a boss that has a lunge attack. He will charge toward the player and specifically target their torso. However, when he charges, he instead just kind of runs to the player and stands right in front of them. I’ve tried making them go behind the torso, but this is not working due to orientation. How can I achieve this?

Entire Script:

local dizz = script.Parent.Humanoid:LoadAnimation(script.Dizzy)
local charge = script.Parent.Humanoid:LoadAnimation(script.Charge)
dizz.Looped = true
charge.Looped = true

function dizzy()
	script.Parent.Dizzy.Value = true
	dizz:Play()
	wait(3)
	dizz:Stop()
	script.Parent.Dizzy.Value = false
end

while wait(math.random(10,11)) do
	charge:Play()
	script.Parent.Humanoid.WalkSpeed = 0
	script.Parent.AI.Disabled = true
	script.Parent.Damage.Disabled = true
	script.Parent.AI.DamageTaken.Value = 60
	local plr = workspace:FindFirstChild(script.Parent.AI.Tracking.Value)
	wait(2)
	charge:Stop()
	script.Parent.Humanoid.WalkSpeed = 55
	script.Parent.Humanoid:MoveTo(plr.Torso.Position)
	script.Parent.Humanoid.MoveToFinished:Connect(function()
		script.Parent.Humanoid.WalkSpeed = 15.9
		script.Parent.AI.DamageTaken.Value = 20
	end)
	dizzy()
	wait(1)
	script.Parent.AI.Disabled = false
	script.Parent.Damage.Disabled = false
end

You could try making the boss offshoot slightly by getting the direction of the player from the boss

local direction = (script.Parent.HumanoidRootPart.Position - plr.HumanoidRootPart.Position).Unit -- You can multiply this to make it offshoot more

and then adding that direction to the player’s position

local targetPosition = plr.HumanoidRootPart.Position + direction

and moving the boss to that position instead?

1 Like

You can use CFrame:ToWorldSpace(CFrame) to get a CFrame relative to the first CFrame offset by the second CFrame, for example

local Part1 = workspace.Part1
local Part2 = workspace.Part2

Part1.CFrame = Part2.CFrame:ToWorldSpace(CFrame.new(0, 0, -5))

Part1 would always be the same position relative to Part2, no matter what orientation or position Part2 is.