How do I detect bullets from a gun?

This is not my own gun system, I’m using ACS.
I’ve made a target that when touched, lightens a part. It works for most things but does not for guns mostly because they use raycasting. How would I detect a bullet/raycast from a gun hitting the character?
Here’s a video:

Thanks.

You can use the Instance of the raycast result (what the raycast touches) :

local raycastResult = workspace:Raycast() -- Put in your raycast info
if raycastResult.Instance.Parent == Target then -- The dummy target
    -- raycastResult.Instance is going to be a body part, so light up whatever body part it is on the screen (i.e. arm or leg)
end

How would I check the raycast from the object that is being hit by it and not by the object that is raycasting it.

local raycastParams = RaycastParams.new({CastingPart}, Enum.RaycastFilterType.Blacklist)
local raycastResult = workspace:Raycast(origin, direction, raycastParams)

if raycastResult.Instance.Parent == Target then -- The dummy target
    -- raycastResult.Instance is going to be a body part, so light up whatever body part it is on the screen (i.e. arm or leg)
end

More info about RaycastParams here

That’s creating a raycast but I want to a part to detect if it’s being hit by a raycast.

As mentioned, raycastResult.Instance is what the raycast hits.

But I can’t go into the ACS Engine script a modify because it’s over a 1000 lines of code, I need something that detects the gun shot. I’m using a .Touched event right now but it doesn’t work. If you know how ACS Engine guns fire, it would be helpful but I think it is a raycast. I want to put a script in the part that is going to be hit by the raycast (not creating it).

As far as I know, you can’t actually detect from a part itself if it’s being hit by a ray cast from somewhere else. The only way is to find out from the ray cast itself so you would need to look in the code i guess.

As far as I’m aware, there isn’t a way. ACS uses raycasting and I don’t think it has anything for this. A possible solution would be to turn each part of the humanoid into a Model, add a Humanoid to that, then detect when the health changed. I haven’t used ACS, so note this only works if the ACS has support for non-player characters.

As a side note, it potentially wouldn’t be that hard to look for where the raycasting happens and add a bit to send that data through a bindable. It might be much more difficult if the ACS uses client sided hit scanning though.

1 Like

I’ll actually try that, that’s a nice alternative for using the touched event. Thank you!

1 Like

There is a way to find the hit detection if you do a check to see if the bullet (located in acs_workspace folder) has touched the part.

Also did you manage to find a solution using raycasting, if so can you post the solution?