Hello! ive been working on a finisher system and im facing an issue with animations playing. When I finisher a dummy it works fine, however when I finisher a player the animation sometimes dosent play and is delayed. If anyone could help me out that would be great!
Thanks for reading
My code:
local function Finisher2()
ContextActionService:BindAction("Finisher2", function(action, state, input)
for _,v in pairs(workspace:GetDescendants())do
local TargetChar = v.Parent
if Character:FindFirstChildOfClass("Tool") then
if v.Name == "HumanoidRootPart" and v.Parent:FindFirstChild("Humanoid") and TargetChar.Name ~= Character.Name and v.Parent:FindFirstChild("Humanoid").Health ~= 0 then
if (Character.HumanoidRootPart.Position - v.Position).Magnitude >=15 and TargetChar.Name ~= Character.Name and v.Parent:FindFirstChild("Humanoid").Health <= 100 and InFatality == false then
if (Character.HumanoidRootPart.Position - v.Position).Magnitude <=20 then
game.ReplicatedStorage.Remotes.TargetCharReplication:FireServer(Character:FindFirstChildOfClass("Tool").Model.Model.Muzzle,TargetChar,Character,"Finisher2")
local FartherDeathAnimation = game.ReplicatedStorage.Assets.FartherDeathAnimation:Clone()
local FartherDeathAnim
FartherDeathAnim = TargetChar.Humanoid:LoadAnimation(FartherDeathAnimation)
local CameraForFinisher = game.ReplicatedStorage.Assets.Camera:Clone()
CameraForFinisher.Parent = workspace
CameraForFinisher:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame * CFrame.new(0,-1,0))
CameraForFinisher.Humanoid:LoadAnimation(CameraForFinisher.Anim):Play()
repeat
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = CameraForFinisher.Camera.CFrame
until workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable
game:GetService("RunService"):BindToRenderStep("Finisher",299,function()
workspace.CurrentCamera.CFrame = CameraForFinisher.Camera.CFrame
end)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
Character.HumanoidRootPart.Anchored = true
InFatality = true
ContextActionService:UnbindAction("MouseHold")
ContextActionService:UnbindAction("Roll")
TargetChar.HumanoidRootPart.CFrame = Character.TargetPart2.CFrame
Anim2 = Character.Humanoid:LoadAnimation(FinisherAnimation2)
Anim2:Play()FartherDeathAnim:Play()
wait(3)
CastModule:RecoilEffect()
for _,v in pairs(Character:FindFirstChildOfClass("Tool").Model.Model.Muzzle:GetChildren())do
if v:IsA("PointLight") or v:IsA("ParticleEmitter") then
v.Enabled = true
end
end
wait(.1)
for _,v in pairs(Character:FindFirstChildOfClass("Tool").Model.Model.Muzzle:GetChildren())do
if v:IsA("PointLight") or v:IsA("ParticleEmitter") and v.Name ~= "smoke trail" then
v.Enabled = false
end
end
wait(1)
for _,v in pairs(Character:FindFirstChildOfClass("Tool").Model.Model.Muzzle:GetChildren())do
if v.Name == "smoke trail"then
v.Enabled = false
end
end
Character.HumanoidRootPart.Anchored = false
InFatality = false
repeat
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
until workspace.CurrentCamera.CameraType == Enum.CameraType.Custom
game:GetService("RunService"):UnbindFromRenderStep("Finisher")
CameraForFinisher:Destroy()
wait(.1)
Character:FindFirstChildOfClass("Tool").Parent = LocalPlayer.Backpack
wait(.1)
LocalPlayer.Backpack:FindFirstChildOfClass("Tool").Parent = Character
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
Roll()
print("Finished")
break
end
end
end
end
end
end, false, Enum.KeyCode.Q)
end
game.ReplicatedStorage.Remotes.TargetCharReplication.OnClientEvent:Connect(function(Muzzle,TargetChar,Char,Type)
if TargetChar.Name == LocalPlayer.Name then
ContextActionService:UnbindAction("MouseHold")
ContextActionService:UnbindAction("Roll")
ContextActionService:UnbindAction("Finisher1")
ContextActionService:UnbindAction("Finisher2")
end
if Type =="Finisher1" then
if Character.Name == Char.Name then
print("Already loaded anim")
else
local Anim_ = game.ReplicatedStorage.Assets.DeathAnimation:Clone()
local Anim
Anim = TargetChar.Humanoid:LoadAnimation(Anim_)
Anim:Play()
end
repeat
TargetChar.HumanoidRootPart.CFrame = Char.TargetPart.CFrame
until wait(.3)
wait(1.3)
local Blood = game.ReplicatedStorage.Assets.BloodPart:Clone()
Blood.Parent = workspace
Blood.Position = TargetChar.Head.Position
for _,v in pairs(Blood:GetChildren())do
if v:IsA("ParticleEmitter") then
v:Emit(50)
end
end
wait(.1)
Muzzle.GunShot:Play()
local BreakEffect = game.ReplicatedStorage.Assets.BreakEffect:Clone()
BreakEffect.Parent = workspace.Ignore
BreakEffect:SetPrimaryPartCFrame(TargetChar.PrimaryPart.CFrame * CFrame.new(0,0,.7) * CFrame.fromEulerAnglesXYZ(0,-0.25,0))
spawn(function()
wait(1)
BreakEffect:Destroy()
end)
else
if Type == "Finisher2" then
if Character.Name == Char.Name then
print("Already loaded anim")
else
local Anim_2 = game.ReplicatedStorage.Assets.FartherDeathAnimation:Clone()
local Anim2
Anim2 = TargetChar.Humanoid:LoadAnimation(Anim_2)
Anim2:Play()
end
repeat
TargetChar.HumanoidRootPart.CFrame = Char.TargetPart2.CFrame
until wait(.5)
TargetChar.HumanoidRootPart.CFrame = Char.TargetPart2.CFrame
wait(3)
local Blood = game.ReplicatedStorage.Assets.BloodPart:Clone()
Blood.Parent = workspace
Blood.Position = TargetChar.Head.Position
for _,v in pairs(Blood:GetChildren())do
if v:IsA("ParticleEmitter") then
v:Emit(50)
end
end
Muzzle.GunShot:Play()
end
end
end)
Here is a video displaying it: