How would I implement an anti-team kill feature into my script?
Asked by
7 years ago Edited 7 years ago
I have this script for a hand axe that I'm making for a game, so far it works perfectly fine. Each time it hits a humanoid it deals damage. However I also want it so that it wont deal any damage to any of the player's team mates, and I have tried using GetPlayerFromCharacter however I am having trouble on figuring out how to use it in my code when the script detects that a humanoid has hit the handle.
Here is the snippet of my code that fixates on hit detection.
03 | Tool.Handle.Touched:connect( function (hit) |
04 | if not swinging then return end |
05 | if not canDamage or not canChop then return end |
09 | hit.Parent:FindFirstChild( "Humanoid" ):TakeDamage( 26 ) |
10 | Tool.Handle.FleshHit:Play() |
17 | local chopValue = hit.Parent.ChopValue |
19 | chopValue.Value = chopValue.Value - addValue |
20 | Tool.Handle.Chop:Play() |
25 | if hit and hit.Parent:FindFirstChild( "Humanoid" ) then |
29 | elseif hit and hit.Parent:FindFirstChild( "ChopValue" ) then |