I have searched for good hitboxes for a while and this one has worked the best so far. The hits are accurate, reliable, and don’t take up too many resources.
Unfortunately, I’m having trouble with getting the rays to follow my model, as they only do so after I’ve hit an NPC:
Here’s the relevant code;
Code registering the hits:
local leftHitbox = raycast:Initialize(stand.LeftLowerArm)
local rightHitbox = raycast:Initialize(stand.RightLowerArm)
local bothHitBox = raycast:Initialize(stand)
local function onHitbox(hit,humanoid)
if humanoid == char.Humanoid then return
else
if barrage.IsPlaying then
humanoid:TakeDamage(barragedmg)
humanoid.Parent.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.LookVector * 30
char.hitlight:Play()
else
humanoid:TakeDamage(damage)
humanoid.Parent.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.LookVector * 100
char.hitlight:Play()
end
end
end
leftHitbox.OnHit:Connect(onHitbox)
rightHitbox.OnHit:Connect(onHitbox)
bothHitBox.OnHit:Connect(onHitbox)
And next, the code calling the raycasts:
elseif func == "punch" then
bounce(0.35)
attacking = true
if punch == "L" then
punch = "R"
leftHitbox:HitStart()
lpunch:Play()
wait(0.05)
stand.Swish:Play()
wait(0.4)
leftHitbox:HitStop()
else
punch = "L"
rightHitbox:HitStart()
rpunch:Play()
wait(0.05)
stand.Swish2:Play()
wait(0.4)
rightHitbox:HitStop()
end
attacking = false
Things I’ve tried:
- Initializing/Deinitializing the hitboxes when they’re needed
- Setting the network ownership of the model
Please help, any would be appreciated.