Making a trace to find the ground's Z

I’m trying to use a trace to find the Z of the ground below a certain prop, but whenever i make the trace outside of the world it makes my game crash. heres the code im using



local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+Vector(0,0,-100000)
local trace = util.TraceLine(tracedata)
local Z = trace.HitPos.z


all i need to do is get the Z of the ground below a prop

Just don’t start the trace outside of the world?

[lua]if util.IsInWorld(pos) then – do your tracing[/lua]

the start is in the world, but i need the end to be outside of the world so i can find the height of the ground. whenever i make the endpos outside of the world it crashes my game. how else can i get the height of the ground below a prop?