RayCastResult.Instance creating error upon returning as nil even though there is an existent else


image
This error keeps printing when my ray.Instance returns as nil even though I have an else statement to provide another function. Sorry if this is explained poorly, it’s very late at night.
Any assistance helps!

3 Likes

Seems that you dont have a RaycastResult.
Check if there is a Result before trying to compare if the Object in the Result is nil or not:

if raycastResult then
   -- Your code
   warn(raycastResult.Instance)
else
   warn("no raycast result")
end
4 Likes

Thank you! I would’ve never probably thought about that, haha

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.