I am working on my damage system for my fighting AI using Region3 and etc. However when I try to get the Humanoid of the Player it keeps saying it’s a nil value. I tried almost anything that I know of and gave up, I could really use some assistance for this.
Code:
local HitBox = function(BodyPart, damage, size, typ, bool)
local hitted = false
if not hitted then
local region = NewRegion(BodyPart.CFrame, size)
for _,v in pairs (CastRegion(char, math.huge, region)) do
if v.Name == "Wall" then return end
if v.Parent:FindFirstChild("HumanoidRootPart") then
local hum = v.Parent:FindFirstChild("Humanoid")
if not hitted and hum then
hitted = true
Damage(typ, damage, hum)
end
end
end
end
if not bool then
hitted = true
end
end
Error: Workspace.Dio.Handler:298: attempt to index local ‘victimHumanoid’ (a nil value)