Checks are not working

I have an AI script for a Soldier, when a bullet touchs something, it does some checks:

if not TouchedObject:IsDescendantOf(script.Parent) or not AlreadyTouched[TouchedObject.Parent.Name] or not table.find(Allies, TouchedObject.Parent.Name) then

However, for any reason those checks are not working, I don’t know if I wrote something incorrectly, please tell me if you need more code that I can show you. I’m currently on phone, thanks for reading.

You should add some print statements for debugging, so you get better understanding of, what actually happens and what values are being used.

A good way, would be to avoid having very long expressions in the if. So break up the expression-parts into individual statements:

print("TouchedObject.Parent.Name=", TouchedObject.Parent.Name)

local isDescendant          = TouchedObject:IsDescendantOf(script.Parent)
local valueInAlreadyTouched = AlreadyTouched[TouchedObject.Parent.Name]
local isInAlliesTable       = table.find(Allies, TouchedObject.Parent.Name)

print("isDescendant=", isDescendant)
print("valueInAlreadyTouched=", valueInAlreadyTouched)
print("isInAlliesTable=", isInAlliesTable)

if (not isDescendant) or (not valueInAlreadyTouched) or (not isInAlliesTable) then

---- Or use a slightly reduced expression:
-- if not (isDescendant or valueInAlreadyTouched or isInAlliesTable) then