I have been working on a project for quite a while. I created a First Person Shooter module and added multiple bullet shots (shotguns). However, whenever I damage a zombie with the spread, it only deals damage once (15 damage). Same applies for all of the shotguns. I have printed marking places and have checked that the code still runs. But it only does one shot of damage!
Sometimes it will do the correct amount of damage and kill the zombie!
Is this a Roblox base code issue or me?
PS I tried posting on roblox dev forum but didnt verify me even after 32 mins read time -_- PPS I realized when this problem happened it made the zombie's health bar flash red?
if roundArray then
for i = 1, #roundArray do
print(roundArray[i][1],"|",roundArray[i][2],"|",roundArray[i][3],"|",roundArray[i][4],"|",roundArray[i][5])
if roundArray[i][3] ~= nil then
hit = roundArray[i][3]
print(hit)
if hit.Parent.Name == "Zombie" then
enemyHum = hit.Parent:FindFirstChild("Zombie")
if hit.Name == "Head" then
damage = self.settings.damageFunc()*1.5
else
damage = self.settings.damageFunc()
end
print("Enemy:", enemyHum)
enemyHum:TakeDamage(damage)
print(damage, "\n")
marker = game:GetService("ReplicatedStorage").HitMarker:Clone()
marker:FindFirstChild("TextLabel").Text = damage
marker.Parent = game.Players.LocalPlayer.PlayerGui
marker.Adornee = hit
marker.Enabled = true
if hit.Name == "Head" then
marker.TextLabel.TextColor3 = Color3.new(1, 1, 0)
end
end
end
end
end

2 comments
I'm not sure if this is memory efficient, but a simple way to do it is to put a ServerScript inside of the bullet to be cloned, and check if it has been touched by a part, if it is, check for a humanoid. If there's a humanoid, then if it's not an actual player, then take damage. Not sure, just a guess.
Sorry about being unclear; I am using raycasting and roundArray is a list which I am iterating through in order to calculate those extra rays. Hope this cleared something up!