So, in my game, I have a enemy character that kills a player with a kill animation, before setting the humanoid health to 0. The only issue I seem to have is correctly positioning the player during said animation. I have videos of how it should look, versus how it plays out when I implement it:
https://drive.google.com/drive/folders/1g_r7TPh3NO1qhYSn7ufJVtbilznLkvMD?usp=sharing
When Implementing this, I use Humanoid:PivotTo() to make it somewhat work, but ive tried to add some vector3 values to line it up correctly. However, it functionally works perfectly, killing the player after the animation and the NPC going on with how it functions.
Below is the function in the script used to make it work, Note that this triggers when within a certain distance when being chased (e.g. when distance < 5):
local function OnTouched(Hit)
if game.Players:GetPlayerFromCharacter(Hit) and attackDebounce == false then
attackDebounce = true
lastTarget = nil
task.wait()
hrp.Anchored = true -- The hrp is the NPC's HumanoidRootPart
Hit:PivotTo(hrp.CFrame)
Hit.HumanoidRootPart.Anchored = true
local VAnimator = Hit.Humanoid:WaitForChild("Animator")
local TAnimator = humanoid:WaitForChild("Animator")
local AttackAnim = TAnimator:LoadAnimation(TelamonAttack)
local PLRAnim = VAnimator:LoadAnimation(VictimAnim)
AttackAnim:Play(0, 1, 1)
PLRAnim:Play(0, 1, 1)
task.wait(0.2)
script.Slash1:Play()
task.wait(0.47)
script.Slash2:Play()
task.wait(1.23)
Hit.Humanoid.Health = 0
hrp.Anchored = false
Hit.HumanoidRootPart.Anchored = false
attackDebounce = false
end
end
This isn’t a huge deal, but I would greatly appreciate some help in understanding how to achieve better results.