Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I move a part behind another part regardless of orientation?

Asked by 2 years ago

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

Thanks!

Answer this question