I’m trying to making so that when melee weapon does a crit strike, it will one-shot the target after playing the execution animation
for some reason when the animation started my character’s torso just went 90 degree
and the target’s animation doesn’t work at all
UPDATE: the Execute animation is working fine now I figured out that it has something to do with directional movement script
but I still have a problem, I want the target to get locked in front of the player, face the player then play the animation which doesn’t work right now.
Weapon script (got it working)
-- service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local TagService = game:GetService("CollectionService")
-- variable
local tool = script.Parent
local Debounce = false
local AttackStep = 1
local rootPart
-- weapon setting
local BaseDamage = 20
local HeavyDamage = 40
local Damage -- to set value later :3
local CritChance = 100 -- Lowest is .1 DO NOT set it to 0 otherwise it will break
local DamageMultiplyer = 1.3 -- how much your crit deal
-- Animation stuff
local Idle = Instance.new("Animation")
Idle.AnimationId = "rbxassetid://82389743504697"
local Slash1 = Instance.new("Animation")
Slash1.AnimationId = "rbxassetid://117195817124320"
local Slash2 = Instance.new("Animation")
Slash2.AnimationId = "rbxassetid://81801466608249"
local Stab = Instance.new("Animation")
Stab.AnimationId = "rbxassetid://116820019801079"
local Execute = Instance.new("Animation")
Execute.AnimationId = "rbxassetid://100383429013256"
local IdleTrack = nil
local SlashTrack1 = nil
local SlashTrack2 = nil
local StabTrack = nil
local ExecuteTrack = nil
-- Creating a hitbox using RaycastHitboxV4 (credit to owner of the module, very cool)
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)
local ignore = {player}
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {ignore}
Params.FilterType = Enum.RaycastFilterType.Exclude
local newHitbox = RaycastHitbox.new(script.Parent)
newHitbox.RaycastParams = Params
local chance = math.round(100/CritChance)
for i, v in pairs(tool:GetDescendants()) do
if v.Name == "GrabBox" then
table.insert(ignore, v)
end
end
local function Execution()
local Performer = script.Parent.Parent:FindFirstChildOfClass("Humanoid")
local DirectionalMovement = script.Parent.Parent:FindFirstChild("Directional movement")
if Performer then
Performer.WalkSpeed = 0
DirectionalMovement.Enabled = false
ExecuteTrack = Performer:LoadAnimation(Execute)
ExecuteTrack.Priority = Enum.AnimationPriority.Action3
ExecuteTrack.Looped = false
ExecuteTrack:Play()
ExecuteTrack.Stopped:Wait()
Performer.WalkSpeed = 18
DirectionalMovement.Enabled = true
end
end
-- basic tool stuff
tool.Equipped:Connect(function()
tool.Model.Anchored = false
IdleTrack = script.Parent.Parent.Humanoid:LoadAnimation(Idle)
IdleTrack.Priority = Enum.AnimationPriority.Idle
IdleTrack.Looped = true
IdleTrack:Play()
end)
tool.Unequipped:Connect(function()
if IdleTrack then
IdleTrack:Stop()
end
end)
tool.Activated:Connect(function()
if Debounce == true then
return
else
Debounce = true
if AttackStep == 1 then
Damage = BaseDamage
SlashTrack1 = script.Parent.Parent.Humanoid:LoadAnimation(Slash1)
SlashTrack1.Priority = Enum.AnimationPriority.Action
SlashTrack1.Looped = false
SlashTrack1:Play()
AttackStep = 2
SlashTrack1:GetMarkerReachedSignal("StartHit"):Connect(function(paramString)
newHitbox:HitStart()
end)
SlashTrack1:GetMarkerReachedSignal("StopHit"):Connect(function(paramString)
newHitbox:HitStop(2)
end)
SlashTrack1:GetMarkerReachedSignal("Interuptable"):Connect(function(paramString)
Debounce = false
end)
elseif AttackStep == 2 then
Damage = BaseDamage
SlashTrack2 = script.Parent.Parent.Humanoid:LoadAnimation(Slash2)
SlashTrack2.Priority = Enum.AnimationPriority.Action
SlashTrack2.Looped = false
SlashTrack2:Play()
AttackStep = 3
SlashTrack2:GetMarkerReachedSignal("StartHit"):Connect(function(paramString)
newHitbox:HitStart()
end)
SlashTrack2:GetMarkerReachedSignal("StopHit"):Connect(function(paramString)
newHitbox:HitStop(2)
end)
SlashTrack2:GetMarkerReachedSignal("Interuptable"):Connect(function(paramString)
Debounce = false
end)
elseif AttackStep == 3 then
Damage = HeavyDamage
StabTrack = script.Parent.Parent.Humanoid:LoadAnimation(Stab)
StabTrack.Priority = Enum.AnimationPriority.Action
StabTrack.Looped = false
StabTrack:Play()
AttackStep = 1
StabTrack:GetMarkerReachedSignal("StartHit"):Connect(function(paramString)
newHitbox:HitStart()
end)
StabTrack:GetMarkerReachedSignal("StopHit"):Connect(function(paramString)
newHitbox:HitStop(2)
end)
StabTrack.Stopped:wait()
Debounce = false
end
end
end)
newHitbox.OnHit:Connect(function(Hit)
if Hit.Parent:FindFirstChildOfClass("Humanoid") then
if Hit.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
local newDamage = math.random(chance) == 1 and Damage * DamageMultiplyer or Damage
if newDamage > Damage then
Execution()
TagService:AddTag(Hit.Parent, "Executed")
Hit.Parent:FindFirstChildOfClass("Humanoid").Health = Hit.Parent:FindFirstChildOfClass("Humanoid").Health - Hit.Parent:FindFirstChildOfClass("Humanoid").MaxHealth
print("Crit!")
else
print("Normal")
end
print("Deal ", newDamage, " Damage")
end
else
return
end
end)
-- when drop a tool and after a few second, anchor the part to prevent it from getting fling around while player is moving
tool.AncestryChanged:Connect(function(child, parent)
if parent == workspace then
tool.Model.CanCollide = true
Debounce = false
AttackStep = 1
wait(2)
tool.Model.Anchored = true
else
return
end
end)
Target script (I have no idea what I'm doing please help me)
local dummy = script.Parent
local hum = dummy:FindFirstChildOfClass("Humanoid")
local CS = game:GetService("CollectionService")
local GettingExecuted = false
hum.BreakJointsOnDeath = false
local function GettingExecuted()
local Execute = Instance.new("Animation")
Execute.AnimationId = "rbxassetid://79302780197661"
local ExecuteTrack = hum:LoadAnimation(Execute)
ExecuteTrack.Priority = Enum.AnimationPriority.Action3
ExecuteTrack.Looped = false
ExecuteTrack:Play()
end
for dummy in CS:GetTagged("Executed") do
GettingExecuted()
end