Hey there! So, i made a script where it constantly raycasts to the player’s humanoid root part checking if it has something.
If it doesn’t, we destroy it.
Now, i did this to check if it doesn’t have it;
1 - Raycast
2 - do if not to check if it doesn’t have it
Now here comes the problem, when the part doesn’t have it, it prints an error.
It still works i guess but i dont want to be spammed by useless errors since it does work.
The code inside the if statement works, it just prints an error everytime. How do i fix this?
Also, i could just make an else statement but the script doesn’t allow me so, i’d have to rewrite the script. Maybe my last resort
I was gonna say something, but @BANSA168 beat me to it.
But anyways yeah, just put that in an if-statement. If the ray doesn’t hit anything, it will return nil which most likely is what is causing the error.
Raycasting is for 3D space and :FindFirstChild is just in what folder something is located, 2 completely different things. There could be a few reasons why it errored, either “a” is nil or it doesn’t have a :FindFirstChild method
If you want to check if there’s something inside raycast’s result instance then you should use the code I sent you and then put your :FindFirstChild code