Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Help with this punch tool?

Asked by 7 years ago
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?
0
This is a less important thing, but take script.Parent.Name out of quotes. It's checking to see if the parent (of the part)'s name is equal to, literally, "script.Parent.Name", and I'm sure your character isn't named script.Parent.Name. RedCombee 585 — 7y
0
Answer? Clakker200 5 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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)

Ad

Answer this question