I came here to ask about HitBox detection for my combat system. What I did for my combat was weld a part to every player named “HitBox.” Once a player clicks, it would use magnitude and raycast to check if any humanoid with “HitBox” was in front/near it. This works pretty fine, but the main issue is some times if you are standing directly in front of that said humanoid. (Like really upclose) the hits won’t register. Is there a better way for hitbox detection or to at least fix this?
Raycasting and magnitude are excellent ways to approach a hitbox system, so I think you’ll want to vest your time into thinking about how to fix this. What strikes me as curious is why your hitboxes wouldn’t register from up close because both are geared well enough to do something like that.
Could you share your current implementation so we can have a better look at what you’re doing?
Range = 7.5
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") and v:FindFirstChild("HitBox") then
local HitBox = v:FindFirstChild("HitBox")
local Human = v:FindFirstChild("Humanoid")
if HitBox and Human and HitBox ~= Character:FindFirstChild("HitBox") then
if (HumanoidRoot.Position - HitBox.Position).magnitude <= Range then
local detecting = Ray.new(HumanoidRoot.Position, HumanoidRoot.CFrame.LookVector * Range)
local hit,position = game.Workspace:FindPartOnRayWithIgnoreList(detecting, {HumanoidRoot})
if hit then
--Do stuff
end
end
end
end
end