Scripting Helpers is winding down operations and is now read-only. More info→
Log in to vote

How can I make a raycast continue through a part so I can get the opposite end from that part?

Asked by 1 year ago

I've tried many things, but none seem to work the way I like.

For example; the part is too far away from the actual opposite end of that part based of the raycast, and all that.

How could I do this? (I am making an entry and exit wound for my game)

1 answer

Log in to vote
Answered by 1 year ago

If you are making entrance and exit wounds, you are probably dealing with single parts, so you can get the other face of the part you are dealing with. However, if you have to deal with multiple parts, you can fire a raycast from the other side that is only whitelisted to the player.

Example of whitelisted raycast:

local raycastParams =
raycastParams.FilterDescendantsInstances = {the_character} --Replace the_character with the actual player character that you are creating an exit wound for.
raycastParams.FilterType = Enum.RaycastFilterType.Include
raycastParams.IgnoreWater = true

local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams) --rayOrigin will be on the other side of the character, and rayOrigin will be opposite to the original raycast
--You then can have the same code to deal with the exit wound as you are using for the entry wound, just with the new raycast result instead.

Answer this question