The NPC has a string value labeled "Owner." The value of the string value states the current owner of the NPC.
The NPC has a sword.
I want to make the sword do damage if it touches a different owner or NPC's with a different owner from its own, not its owner or NPC's with the same owner. (Make sword deal damage if it touches an enemy owner or enemy NPC, not own owner or ally NPC)
Thank you.
local Sword = script.Parent local Handle = Sword.Handle local Owner = Sword.Parent.Stats.Owner local Stats = Sword.Stats local DamageValue = Stats.Damage local function onTouch(Part) local ObjTch = Part.Parent if game.Players:GetPlayerFromCharacter(ObjTch) then if (ObjTch.Name == Owner.Value) then ObjTch.Humanoid.Health = ObjTch.Humanoid.Health - DamageValue.Value print("Damaged") wait(3) end end end Handle.Touched:connect(onTouch)
"ObjTch" means Object Touched