I want to make the npc not damage the player when player is blocking with their sword, and get parried if parry value inside the player was true, the grey block is BlockHitbox.
Issue is that it rarely hits the BlockHitbox and damages player, usually hits head or arm instead of the BlockHitbox.
Should i make the BlockHitbox bigger? is there something wrong with my hit detection?
local hitCache = {}
local par = false
local hit = false
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {model}
local hitbox = ShapecastHitbox.new(blade, raycastParams)
task.spawn(function()
task.spawn(function()
task.wait(settings.BeforeSlashSound)
Utils.playSlashSound(settings, model)
end)
task.wait(settings.TimeToParry[state.combo])
blade.CanTouch = true
hitbox:HitStart(3):OnUpdate(function()
if hitbox.RaycastResult then
local part = hitbox.RaycastResult.Instance
local char = part:FindFirstAncestorOfClass("Model")
if not char or not char:FindFirstChild("Humanoid") then return end
if hitCache[char] or (not state.attacking and not state.stunned) then return end
hitCache[char] = true
print(part.Name)
local targetHumanoid = char:FindFirstChild("Humanoid")
local blee = true
if helper then
if char ~= owner.Character then
blee = false
end
end
if part.Name == "BlockHitbox" and not par and not hit and blee then
if char:FindFirstChild("Parry").Value == true then
local p = Combat.Parried(state, model, blade, target, root, state.hitConnection, humanoid, etype, track)
par = true
else
Combat.Blocked(model, blade, root)
end
else
if not par and not hit then
local isHelperHittingPLayer = true
if not char:FindFirstChild("Evil") and helper then
isHelperHittingPLayer = false
end
if isHelperHittingPLayer then
local h = Combat.Damage(etype, targetHumanoid, char, part, settings)
if h then hit = true end
end
end
end
end
end)
end)
ShapecastHitbox.Settings.Debug_Visible = true
track.Stopped:Connect(function()
state.combo = (state.combo % #settings.animations) + 1
hitbox:HitStop():Destroy()
state.attacking = false
model.Attacking.Value = false
end)
continue
end
Any help is appreciated
