Name detection Wont work

im trying to make it so that you can’t damage a friendly npc, but you cant damage nobody for some reason


			if not closecharacter.Parent.Name == "FriendlyNPCs" then
				if closecharacter.HumanoidRootPart:FindFirstChild("IsBlocking") then
				          print("can attack")
						end	
					else
						-- your behind him
						if 	(closecharacter.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Magnitude < 7 then
							print("hitting from behind")	
						end
					end
				else
					closecharacter.Humanoid:TakeDamage(7)
					end)
				end
			end
		end
		player.FistXp.Value = player.FistXp.Value + 1
	end
end)

help

Maybe try changing this line to

if closecharacter.Parent.Name ~= "FriendlyNPCs" then

Where does it stop printing?

it does not print can attack at all, doesnt even get inside the if statement

So it neither prints can attack nor hitting from behind? I think it has to be the condition I pointed out, maybe try changing that line to what I suggested?

yep, i tested, and it works, I honestly didnt know this until now, thanks for the help

1 Like

Anytime! That if statement did make me question if that was t he cause since I never saw that be made like that, I think the code thought you were trying to see if the name was false/empty and then compared false to “FriendlyNPCs”, but we can only speculate on taht

If you have anymore issues don’t be afraid to make another post!