The part with the damage script in it is in Lighting. Using a script in a tool I clone it into workspace, but it hurts me, the person who cloned it. How can I make it not hurt whoever summoned the clone? I've tried all kinds of crazy things to no avail.
hurt = true function touch(hit) if hurt == true then humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health -30 hurt = false wait (0.1) hurt = true end end end script.Parent.Touched:connect(touch)
Check if the tool isn't a descendant of the humanoid's parent (the character).
local tool = script.Parent script.Parent.Touched:Connect(function(hitPart) if not tool:IsDescendantOf(hitPart.Parent) then -- ... end end)
I like to use StringValues to achieve this, but I'm sure there are probably better ways to do this.
So, whenever you clone the part with the damage script, insert a StringValue in there called 'Owner' or whatever you'd like, and set the value to the name of the person that you do not want to hurt.
Afterwards, in the projectile script, just add an if statement to check if the person who was hit is the value in the StringValue.
If you would like to see some example code, just ask.