How to find if a player's head is within a part?

It might be that the collision is on for the wall?

Did you even read my message? I said that the ray cannot land while the head is inside the wall.

I did read your message, and I’m trying to help. I don’t know what to do in that case besides making a script to change it. Try not to be rude when someone is attempting to help you.

I’m sorry it’s just infuriating when someone asks me if I have my wall’s collision off correctly when I clearly state in the message that the ray is not hitting while my head is inside the wall. And, oh wow, make a script to change it, who would’ve thought?

I’m just saying isn’t that obvious? Plus it’s always good to check the collision.

Of course it’s obvious! But why would I need to ask for help just for someone to tell me to “change the script”? I’m not trying to be rude to those trying to assist me, but like, no offence, but you’re not really helping…

Okay then, I’ll stop trying to help you. You can’t expect me to go and think of a script right now that will fix the problem. Just experiment with it to see what works.

I don’t expect you to give me a script. I was asking a question to see if someone knew how to detect a part while inside of it by using rays or some other method. But you just rushed in with an answer saying “change the FOV when exiting the part”. I appreciate your attempt to help, but really, I think I’ll ask someone else.

I respect your view, and I’m sorry if I didn’t help. I just figured that it can’t hurt to try.

Region3 is always a possibility.
Though I don’t know about performance if you are constantly checking.

Thanks for the reply. Unfortunately, region3 is not possible as parts will have to each be individually identified and scripted, and because there are diagonal parts and meshes. It would be preferable to stick to the old method. Do you know if there’s a way to make these parts not fail when inside a part?

You could within the raycast parameters ignore the wall they are currently within.

What would ignoring the wall do? That’ll guarantee that the ray doesn’t hit the wall. I want it to hit the wall when the player is inside of it.

I don’t have the best knowledge about RayCasting so someone who knows better could help but if your attempting to fire a ray from inside another part pretty sure it will just ignore it. I’ll do some testing of my own and tell you the results.

1 Like

Adding onto this I just tested firing a ray from a parts LookVector and got returned nil as soon as I located the part within a wall.


Using :GetTouchingParts() seemed to work though.

You could try raycasting across a players head (x axis) or from back to front of the players head (z axis), by getting an vector from the left and right side of the players head, respectively. Using these two vectors, you can construct a unit vector that runs across them. I haven’t tested, but I do find recommend using other alternatives such as the above, because raycasting is not really needed here.

local runService = game:GetService('RunService')
local player = game:GetService('Players').LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild('Head')

local raycastParams =
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {character}
raycastParams.IgnoreWater = true

   local origin = (head.CFrame *,0,0)).Position
   local endOrigin = (head.CFrame *,0,0)).Position
   local direction = (origin-endOrigin).Unit * -head.Size.X
   local ray = workspace:Raycast(origin, direction, raycastParams)
   if ray then
      	print("Object/terrain hit:", ray.Instance:GetFullName())

ROBLOX’s new OverlapParams can do what Regions3 do but with orientation. Check out WorldRoot:GetPartsInPart().

Thank you. I will give getTouchingParts a try.

.Touched and TouchEnded or GetTouchingParts(GetTouchingParts returns a table of touching parts) BasePart:GetTouchingParts (

Hey. Your method of using getTouchingParts worked great. Thanks for your help