The code works perfectly fine but when mobs start going in each other the raycast params just seem to ignore it which is kind of annoying since I want to hit all mobs regardless if theyre inside each other.
for _, MobInstance in CollectionService:GetTagged("Mob") do
local Torso = MobInstance:FindFirstChild("Torso")
and MobInstance.Torso
if not Torso then
return
end
local Raycast = RaycastParams.new()
Raycast.FilterType = Enum.RaycastFilterType.Exclude
Raycast.FilterDescendantsInstances = {Character, MobInstance}
local Resultant = Torso.Position - CharacterTorso.Position
local Normal_Resultant = Resultant.Unit
local Distance = Resultant.Magnitude
local Dot = Look:Dot(Normal_Resultant)
local Rad_Angle = math.acos(Dot)
local Deg_Angle = math.deg(Rad_Angle)
local In_Range = Distance <= Range
local In_View = Deg_Angle <= Angle
local Is_Hit = In_Range and In_View
local True_Resultant = workspace:Raycast(CharacterTorso.Position,Resultant,Raycast)
if not True_Resultant and Is_Hit then
task.spawn(function()
RequestStunMob(MobInstance, StunValue)
Knockback:Activate(Torso, KnockbackValue, Position, Torso.Position)
if Damageable then
Damage:DamageMob(Player, MobList[MobInstance], {Ignore = DamageIgnore, Damage = DamageValue})
end
pcall(function()
Torso:SetNetworkOwner(Player)
end)
end)
end
end