Error - invalid argument #2 (Vector3 expected, got nil)

Hello! I’m currently working on a JJBA game.
Recently, I’ve come over this Vector3 bug in my hitbox script.
The error is in the 7th line.

function hitting(damagepart, magnitude, dmg, debtime)
	for i, v in pairs(workspace:GetChildren()) do
		if damagepart.Anchored == true then return end
		if v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") and v ~= char then
			if damagepart.Anchored == true then return end
			local humrp = v:FindFirstChild("HumanoidRootPart")
			local dist = (humrp.Position - damagepart.Position).Magnitude
			if dist > magnitude then
				local huamnoid = v:FindFirstChild("Humanoid")
				sdamageevemt:FireServer(humanoid, damagepart, dmg, debtime)
			end
		end
	end
end

function that runs the above function:

function standBarrage()
	if sappear == false then return end
	if moveactive == true then return end
	if barragecd == true then return end
	if barraging == true then return end
	-- if all above statements are false, then continue
	barragecd = true
	barraging = true
	SBarrageAnm:Play()
	repeat
		barragelength = barragelength + 1
		advancedtrail:FireServer(Color3.fromRGB(128, 0, 128)) -- trail
		hitting("Stand Left Arm", 2, 3.5, .6)
		hitting("Stand Right Arm", 2, 3.5, .6)
		wait(.1)
	until barragelength == 40
	SBarrageAnm:Stop()
	moveactive = false
	-- cooldown
	wait(3)
	barragelength = 0
	barragecd = false
	barraging = false
end

Any help would be appreciated, if it’s an obvious/minor mistake that could be solved easily then I’m blaming it on myself, Not much of a scripter so…
Thanks!

Because you didnt even actually refer the damage part, you only mentioned the name but not the instance itself

1 Like

Ah. So that’s what was happening.
Thanks a lot for the solution!