You will need to add another check.
Example
remote.OnServerEvent:Connect(function(plr)
local character = plr.Character
local newPart = Instance.new("Part")
newPart.Anchored = true
newPart.Position = Vector3.new(0,0,0)
newPart.Touched:Connect(function(hit)
if hit:IsDescendantOf(character) then return end
print("KONO DIO DA")
end)
end)
The touched event sends the part that was touched as a parameter. Using :IsDescendantOf() is a check to see if the part that was touched is a part of the players character
5 comments
i didnt really get that but yeah
To reiterate. The .Touched signal fires when contact is made with the affiliated BasePart, I.e a Collision-Detection. The signal will call upon the bound callback, and pass the part-of-contact along with it.
That part-of-contact, in PvP, is normally a body part in a Character rig. With that we can locate a Humanoid and call :TakeDamage().
The Hitbox integrated into the Tool has a chance of detecting the wielder, though, in our code we don't accommodate for that, therefore we still proceed with dealing damage to a Humanoid.
In the program above, Despayr adds a debounce line that checks whether the part-of-contact is a descendant of your avatar's rig. If so, the function is then halted with the return call, and effectively canceled.