Hi I’ve started implementing ShapecastHitbox into my game and I love the plugin too. Thank you for making something so amazing. I just have a bug that I can’t seem to get around with how OnHit() works with HitStop()
From one of my client scripts I’m passing in multiple parameters like combo, chargeLevel, etc which are used in calculating final damage in a server script. For some reason even when calling HitStop(), it seems like the OnHit() connection only uses the variables passed on the very first creation of the OnHit() listener. I’ve tried assigning it to a connection variable but it won’t allow me to disconnect it as it’s not a connection object being made in the first place.
The only way I’ve managed to get around this is destroying and recreating the hitbox on every call, but this feels like it would be very unoptimized especially when player counts get larger. Is this intended or is there something I’m missing? Below is the code.
Thank you so much for your hard work! I look forward to future updates.
type or paste code herefunction HitboxClient.CreateGearHitbox(hitboxPart, typeSort, dualWielding)
if not dualWielding then
if HitboxClient.weaponHitbox then HitboxClient.weaponHitbox:Destroy() end
local gearHitbox = shapeCastHitbox.new(hitboxPart)
HitboxClient.weaponHitbox = gearHitbox
else
if HitboxClient.weaponDualWieldHitbox then HitboxClient.weaponDualWieldHitbox:Destroy() end
local gearHitbox = shapeCastHitbox.new(hitboxPart)
HitboxClient.weaponDualWieldHitbox = hitboxPart
end
end
function HitboxClient.StartMeleeHit(lightOrHeavy : string, combo : number, invID : number, chargeLevel : number)
local hitbox : shapeCastHitbox.Hitbox = HitboxClient.weaponHitbox
local targetsHit = HitboxClient.targetsHit
hitbox:HitStart():OnHit(function(raycastResult, segmentHit : shapeCastHitbox.Segment)
local playerTargetHit = raycastResult.Instance.Parent:FindFirstChild("Humanoid")
local enemyNPCTargetHit = raycastResult.Instance.Parent:FindFirstChild("NPC")
if targetsHit[playerTargetHit] == true then return end
if targetsHit[enemyNPCTargetHit] == true then return end
if playerTargetHit then
-- TODO FIX CONNECETION ISSUE HITBOX KEEPS REUSING OLD HITSTART
targetsHit[playerTargetHit] = true
signal.FireServer("CharacterCombatServer:MeleeHitPlayer", playerTargetHit, lightOrHeavy, combo, raycastResult.Position, invID, chargeLevel)
end
if enemyNPCTargetHit then
targetsHit[playerTargetHit] = true
-- TODO
end
end)
end
function HitboxClient.StopMeleeHit()
local hitbox = HitboxClient.weaponHitbox
table.clear(HitboxClient.targetsHit)
hitbox:HitStop()
end