function onDamage(Part) if Part.Parent:FindFirstChild("Humanoid")~= nil and Part.Parent.Name ~= "script.Parent.Name" then Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -3.4 end end script.Parent.Parent.Parent.Character["Left Arm"].Touched:connect(onDamage) --It works but I want it to only damage when I press q the problem is when I touch a humanoid My left arm damages them when I dont want them to.Help?
You are checking to see if the parent of the part's name is equal to the string, "script.Parent.Name".
e.g: is the parts name equal to Script.Parent.Name
So try this instead:
script.Parent.Parent.Parent.Character["Left Arm"].Touched:connect(function() if Part.Parent:FindFirstChild("Humanoid")~= nil and Part.Parent.Name ~= script.Parent.Name then Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -3.4 end end)