you would have to cast a ray downwards from a higher position
local origin = humrp.Position + Vector3.new(0, 100, 0) --however high up you need to start
local direction = Vector3.new(0, -100, 0) -- point down 100 studs
--cast - get your results - the first thing hit will be the 'highest' object or nil if you've filtered out your player's character in RaycastParams - meaning there's nothing above you.
by the way - just so you know, doing:
local direction = humrp.CFrame.UpVector
will point upwards relative to your player’s character.
This means, if the player falls over for any reason and the cast is made - the ray won’t point straight up, but in whichever direction the top of your character is facing.
Hence why I swapped in the Vector3.new(0, -100, 0)
but if you need relativeness that is fine then.
Finally, I think LookVector / UpVector might be a Unit - (e.g. - V3.new(0, 100, 0) == V3.new(0, 1, 0) - so if you need the ray to cast for a longer distance, you’ll like need to multiply by the distance you need.
local direction = humrp.CFrame.UpVector.Unit * 100 -- definitely traveling 100 studs above the character's head
This is important for ray casts as the ray will only travel as far as the magnitude of the direction value.