i created a script that when you touch, if you isnt the owner(all players, but will hurt only other players, and not himself), you will get hurt,this script is for a combat system, i put this script in the arms and legs of each player, but dont work, what i did wrong?
local debounce = false
local HealthLoss = 14
function OnTouched(Part)
if script.Parent.Parent.Name == Part.Parent.Name then
else
if Part.Parent ~= nil then--Keep Parentless blocks from breaking it.
if debounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then
debounce = true
Part.Parent:findFirstChild("Humanoid"):TakeDamage(HealthLoss)
wait(0.2)--Wait two seconds before the brick can hurt someone.
debounce = false
end
end
script.Parent.Touched:connect(OnTouched)

1 comment
what is the error?