How to know if a ray hit a part

Specifically I want to get the ray through the part that was hit if that makes any sense.

feel free to ask any questions


1 Like

Wrong. If WorldRoot:Raycast does not intersect a part or terrain cell within the specified distance, it returns nil.

local ray = workspace:Raycast(,10,0),,-10,0))

if ray then

print(ray.Instance.Name) -- SpawnLocation (that is if you have an unchanged baseplate template)

1 Like

Obviously, but the thread’s poster was asking how to get the part that was hit (at least from what I was able to decipher).

the part that was hit

Additionally, Workspace:Raycast() does not receive a ‘distance’ parameter, it receives parameters for an ‘origin’, a ‘direction’ and a ‘raycast parameters object’.

My bad. I misread what the OP was asking.