So I have a script that casts multiple raycast around the players head as shown in the picture below
and when the raycast hits an enemy it decreases their HP once but since their are other raycast near it it also hits the same enemy casuing it to double the damage
now what I want to do is if that part is already hitted by a ray then the other rays shouldn’t
interfere that enemy
I tried adding debounce and other methods but I still can’t seem to figure it out
You can add the part to a table once it is hit, and then when you cast the next ray add a filter list with that table.
So I Should get all the enemys Part into a filter list?
btw guys this is my code
local param = RaycastParams.new()
param.FilterDescendantsInstances = {gun, gun.Particle}
param.FilterType = Enum.RaycastFilterType.Blacklist
param.IgnoreWater = true
local direction = plr.Character:FindFirstChild("Head").CFrame.LookVector * 50
local ray = {
game.Workspace:Raycast(plr.Character:FindFirstChild("Head").Position, direction, param),
game.Workspace:Raycast(plr.Character:FindFirstChild("Head").Position, direction + Vector3.new(0, 0, 20), param),
game.Workspace:Raycast(plr.Character:FindFirstChild("Head").Position, direction + Vector3.new(0, 0, -20), param),
game.Workspace:Raycast(plr.Character:FindFirstChild("Head").Position, direction + Vector3.new(0, 0, 10), param),
game.Workspace:Raycast(plr.Character:FindFirstChild("Head").Position, direction + Vector3.new(0, 0, -10), param),
}
for i, v in pairs(ray) do
if v.Instance and v.Instance.Parent:FindFirstChildWhichIsA("Humanoid") and v.Instance.Parent:FindFirstChild("Enemy") then
v.Instance.Parent:FindFirstChildWhichIsA("Humanoid"):TakeDamage(10)
end
end
task.wait(0.4)
debounce = true
end```