That’s exactly what I’ve been doing, however instead of checking the distance between the parts above and below after org 3. I just don’t allow the vault since if it didn’t hit something between org 2 and org 3, then there’s obviously nothing in between the two parts, so checking the distance between them is redundant.
I believe this would accomplish the basics.
--Cast 1, Forward relative to character
local cf = char.HumanoidRootPart.CFrame
local castDist1 = 10
local castResult = workspace:Raycast(cf.Position, (cf.LookVector*castDist1), CastParams)
if(castResult)then
--Adjust position a bit more Forward relative to character
local newPos = castResult.Position + (cf.LookVector * .05)
--Cast 2, From Adjusted Hit Position, Upward relative to world space
local castDist2 = 20
local castResult2 = workspace:Raycast(newPos, (Vector3.new(0,1,0)*castDist2), CastParams)
if(castResult2)then
--Cast 3, back down from the surface we hit above the first object detected
local castResult3 = workspace:Raycast(castResult2.Position, (Vector3.new(0,-1,0)*castDist2), CastParams)
if(castResult3)then
--Distance between parts is:
local gapDist = (castResult2.Position - castResult3.Position).Magnitude
print("The gap is", gapDist, " studs in height.")
end
else
--Nothing was hit, this could mean there is nothing there.
--But the object could still be far to tall to vault..
--So perhaps at this point you calculate the distance between the top surface of the first object hit
--and the character position to determine if the character can jump/vault over it.
end
end