Hello, so im making a explosion and i want it to kill people when they are in the radius, but i dont want them to die if they are inside a building and say the explosion is outside of the building and it still kills them. I tried raycasting from the players head to the explosion position to see if theres a part obstructing it, but its was very inaccurate, heres the code for that.
Sorry about the late Reply! Better late than never.
Check for every body part instead of just the head and ignore the HumanoidRootPart. Why ignore it? Some crouching systems are weird and don’t work correctly. This just helps with the hassle.
Seems like your Ray.new call is incorrect. The second parameter should NOT be where you want the ray to go, it should be the direction to where you want it to go. Try
use workspace:GetPartBoundsInRadius to get all the players inside of the explosion, loop through them, and do a raycast check similar to what @ThanksRoBama suggested
that way you dont have to loop through every humanoid
also Ray.new() is deprecated and I suggest using workspace:Raycast()