So It works, the block and parry and more but when you died 1 time the sword will not work anymore. It says Infinite yield possible on HumanoidRootPart after dying 1 time. pls help me how to fix this
here the code:
local sword = script.Parent
local attackRemote = script:WaitForChild("Attack")
local blockRemote = script:WaitForChild("Block")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local HumRP = char:WaitForChild ("HumanoidRootPart")
local anims = script:WaitForChild("Anims")
local equippedIdle = hum:LoadAnimation(anims:FindFirstChild("IdleEquipped"))
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local Modules = RS:WaitForChild("Modules")
local Remotes = RS:WaitForChild("Remotes")
local runRemote = Remotes:WaitForChild("Run")
local equipRemote = Remotes:WaitForChild("Equip")
local RaycastHitbox = require(Modules:WaitForChild("RaycastHitboxV4"))
local Combo = 1
local DoingCombo = 0
local M1Debounce = false
local isEquipped = false
local Animations = script:WaitForChild("Animations")
local blockIdle = hum:LoadAnimation(Animations:FindFirstChild("BlockIdle"))
local CanBlock = true
local isBlocking = player:WaitForChild("isBlocking")
local m1CDs = {
[1] = 0.50,
[2] = 0.33,
[3] = 0.45,
[4] = 1
}
local m1HT = {
[1] = 0.33,
[2] = 0.33,
[3] = 0.33,
[4] = 0.33
}
local m1HitStartDelay = {
[1] = 0.17,
[2] = 0.17,
[3] = 0.17,
[4] = 0.17
}
local m1HitDuration = {
[1] = 0.18,
[2] = 0.18,
[3] = 0.18,
[4] = 0.18
}
local M1Animations = {
[1] = hum:LoadAnimation(Animations:WaitForChild("Attack1")),
[2] = hum:LoadAnimation(Animations:WaitForChild("Attack2")),
[3] = hum:LoadAnimation(Animations:WaitForChild("Attack3")),
[4] = hum:LoadAnimation(Animations:WaitForChild("Attack4"))
}
sword.Equipped:Connect(function()
equippedIdle:Play()
isEquipped = true
hitbox = RaycastHitbox.new(sword.Blade)
equipRemote:FireServer("Equip")
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {char} --- remember to define our character!
Params.FilterType = Enum.RaycastFilterType.Blacklist
hitbox.RaycastParams = Params
hitbox.OnHit:Connect(function(hit, humanoid)
if humanoid then
if not humanoid.Parent:FindFirstChild("Immune") then
attackRemote:FireServer(HumRP, humanoid, "Hit", DoingCombo)
end
end
end)
end)
sword.Unequipped:Connect(function()
equippedIdle:Stop()
isEquipped = false
if hitbox then
hitbox:Destroy()
end
equipRemote:FireServer("Unequip")
blockRemote:FireServer(HumRP, hum, "Unblock")
blockIdle:Stop()
end)
sword.Activated:Connect(function()
if not M1Debounce and not player:FindFirstChild("isBlocking").Value and not char:FindFirstChild("Disabled") then
runRemote:FireServer("Walking")
if Combo == 1 then
Combo = 2
DoingCombo = 1
delay(1, function()
if Combo == 2 then
Combo = 1
end
end)
M1Debounce = true
delay(m1CDs[DoingCombo], function()
M1Debounce = false
end)
M1Animations[DoingCombo]:Play()
elseif Combo == 2 then
Combo = 3
DoingCombo = 2
delay(1, function()
if Combo == 3 then
Combo = 1
end
end)
M1Debounce = true
delay(m1CDs[DoingCombo], function()
M1Debounce = false
end)
M1Animations[DoingCombo]:Play()
elseif Combo == 3 then
Combo = 4
DoingCombo = 3
delay(1, function()
if Combo == 4 then
Combo = 1
end
end)
M1Debounce = true
delay(m1CDs[DoingCombo], function()
M1Debounce = false
end)
M1Animations[DoingCombo]:Play()
elseif Combo == 4 then
Combo = 1
DoingCombo = 4
M1Debounce = true
delay(m1CDs[DoingCombo], function()
M1Debounce = false
end)
M1Animations[DoingCombo]:Play()
end
delay(m1HitStartDelay[DoingCombo], function()
if hitbox then
hitbox:HitStart(m1HitDuration[DoingCombo])
attackRemote:FireServer(HumRP, hum, "Trail", DoingCombo, sword)
end
end)
end
end)
local blockInput = Enum.KeyCode.F
UIS.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if isEquipped and CanBlock then
if Input.KeyCode == blockInput then
if not player:FindFirstChild("isBlocking").Value and not char:FindFirstChild("Disabled") then
blockRemote:FireServer(hum, "Block")
runRemote:FireServer("Walking")
end
end
end
end)
UIS.InputEnded:Connect(function(Input, IsTyping)
if IsTyping then return end
if isEquipped then
if Input.KeyCode == blockInput then
blockRemote:FireServer(hum, "Unblock")
end
end
end)
hum.Died:Connect(function()
blockRemote:FireServer(hum, "Unblock")
end)
isBlocking:GetPropertyChangedSignal("Value"):Connect(function()
if isBlocking.Value == true then
blockIdle:Play()
else
blockIdle:Stop()
end
end)
blockRemote.OnClientEvent:Connect(function(canBlock, action)
local breakBlockAnim = hum:LoadAnimation(Animations:FindFirstChild("BlockBroken"))
CanBlock = canBlock
if action == "Break" then
breakBlockAnim:Play()
wait(3)
breakBlockAnim:Stop()
CanBlock = true
end
end)

1 comment
ive only post the local