Hello, I am trying to make a weapons system–mainly projectiles with piercing and more aspects, but the piercing does not work. After finding one part, the whole loop proceeds to not find any more.
local checkForParts = coroutine.create(function(part, currType)
while part ~= nil do
wait()
local gotten = game.Workspace:GetPartsInPart(part, filter)
for _, thing in pairs(gotten) do
if thing.Parent:FindFirstChild("Humanoid") and hitDb[thing.Parent] == nil then
hitDb[thing.Parent] = true
if currType == "Normal" and script.CurrentWeapon.Value == "Slingshot" or piercingEnabled == true and script.CurrentWeapon.Value == "Slingshot" then
game.ReplicatedStorage:WaitForChild("TakeDmg"):FireServer(thing.Parent.Humanoid, 10)
elseif currType == "Poison" and script.CurrentWeapon.Value == "Slingshot" then
coroutine.resume(tickDmgFunc, thing.Parent.Humanoid, slingAddons[1][3], 7)
elseif currType == "Burn" and script.CurrentWeapon.Value == "Slingshot" then
coroutine.resume(tickDmgFunc, thing.Parent.Humanoid, slingAddons[2][3], 10)
end
if currType == "Normal" and script.CurrentWeapon.Value == "Sword" then
if swordCombo == 1 then
game.ReplicatedStorage:WaitForChild("TakeDmg"):FireServer(thing.Parent.Humanoid, 10)
elseif swordCombo == 2 then
game.ReplicatedStorage:WaitForChild("TakeDmg"):FireServer(thing.Parent.Humanoid, 15)
end
end
local co
if script.CurrentWeapon.Value == "Slingshot" then
co = coroutine.create(function()
task.wait(0.5)
hitDb[thing.Parent] = nil
end)
elseif script.CurrentWeapon.Value == "Sword" then
co = coroutine.create(function()
task.wait(0.6)
hitDb[thing.Parent] = nil
end)
end
coroutine.resume(co)
if piercingEnabled == true then
if pierceAmt < slingAddons[3][3] then
pierceAmt += 1
individualThingy[part.Name] = thing
elseif pierceAmt >= slingAddons[3][3] then
individualThingy[part.Name] = thing
return
end
elseif currType ~= "Piercing" then
individualThingy[part.Name] = thing
return
end
print(part.Name, individualThingy[part.Name])
return
elseif not thing.Parent:FindFirstChild("Humanoid") then
if piercingEnabled == true then
if pierceAmt < slingAddons[3][3] then
pierceAmt += 1
individualThingy[part.Name] = thing
elseif pierceAmt >= slingAddons[3][3] then
individualThingy[part.Name] = thing
return
end
elseif currType ~= "Piercing" then
individualThingy[part.Name] = thing
return
end
end
end
end
end)
(sorry for the messy code, and the bad formatting)