Constant error with sword tool

Hey! I’m simply creating this sword and it has a pretty basic script but it works. The issue is is that everytime it hits something that doesn’t have a humanoid it spits out a error, even if it shouldn’t be (i think it should not do it anyways). So I’m asking if someone can help me disable this error.

Screenshot 2021-11-16 215228

local SwordTop = script.Parent.SwordTop
local tool = script.Parent

		if obj.Parent:FindFirstChild("Humanoid") then
			local h = obj.Parent.Humanoid
			local m = math.random(2.5, 5.4)
			h.Health -= m

Because when the sword touch something, it will try every single time to find the first child called “Humanoid” inside each Obj… And if “Humanoid” is nil or not inside the Child, then it will thrown an error because the main function is to find that child when the Sword touch something.

well, try this:

if obj.Parent:FindFirstChild("Humanoid") ~= nil then
1 Like

That still doesn’t work, obj.Parent:FindFirstChild(“Humanoid”) already does that i think in a if then statement. And when the sword hits it for some reason saves the humanoid health so everytime it hits, it damages the humanoid, without even being on the player. I think this is from the error.