Okay so I have this combat system and it seems to work fine except for one part.
for i,v in pairs(GetTouchingParts(char[wponName][weapon].hitbox)) do
local db = false
if v.Parent:FindFirstChild("Humanoid") then
for t,h in pairs(hittable) do
if v:IsDescendantOf(char) then
db = true
elseif v.Parent == h then
db = true
end
end
if db == false then
table.insert(hittable,1,v.Parent)
-- damage is dealt.
obviously thats not the full script but thats the part im stuck on. (where the problem occurs)
INTENDED TO DO: When you swing a weapon it gets all the touching parts and returns them. It cycles through them and since theres a chance it can grab two of your body parts the loop can run and damage the victim twice. To prevent this the loop grabs the players character and puts it into a table after its damaged once. If anything is in that table then damage wont register. It also checks if the parts belong to the person doing the attack by checking if its a descendant of the character.
WHAT IT DOES: It can hit the player doing the attack for some reason despite my measure to stop it. Everything else seems to work fine except the fact that I can hit myself.