local player = game.Players:GetPlayerFromCharacter(attacker)
local attackercharacter = attacker
local attackerhum = attackercharacter.Humanoid
local alive = game.Workspace.Alive:GetChildren()
local hitbox = CFrame.new(x,y,z) * attackercharacter.HumanoidRootPart.CFrame.LookVector
for i = 1,#alive do
local victim = alive[i]
if victim ~= attackercharacter then
local attackerFrame = attackercharacter.HumanoidRootPart.CFrame.Position
local victimFrame = victim.HumanoidRootPart.CFrame.Position
if math.abs(attackerFrame.Magnitude - victimFrame.Magnitude) <= hitbox.Magnitude then
print("Hit")
end
end
end
Having some trouble with making hitboxes. Im sending coordinates and the attacker char to the module and its supposed to check. I decided to do it like this, by comparing them. But im having some trouble with it for some reason. Sometimes the hitbox is too big or a little clunky. xyz are 3,3,3
example: prints hit even though hitbox is supposed to be like this. Think im doing something wrong with calculations