Why does this hurt the player that pressed the key rather than the person getting touched. I don't want the player who pressed the key to be harmed. This script is cloned into a part that shoots. When the player presses a button the part is fired
function onDamage(Part) if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= script.Parent.Name then script.Disabled = true f = Instance.new("Fire", Part) f.Color = Color3.new(1, 0, 0) for i = 1,25 do f.Size = f.Size +0.25 Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -2.5 wait(0.05) end Part.Parent.Humanoid.Sit = true f:remove() script.Parent:remove() end wait(0.025) end script.Parent.Touched:connect(onDamage)
Since you only gave us a portion of the code, we aren't able to provide much help. The only guess I could think of, is that when it fires the 'bullet', it touches the owner in the process. I recommend making an if statement to make sure the 'bullet' can't hurt the owner of the bullet.