Help with Raycasting constantly resulting in nil in the output

My issue is the topic name. raycasting is constantly resulting in nil in the output. can someone tell me whats wrong and how to fix it?



image

Nothing wrong. If it’s nil, the ray simply did not hit anything (the player could be aiming at the sky or something). Make sure you use an if statement to check if the ray has hit something.

1 Like

The thing is I was clicking at the wall or the dummies I placed. And for the If statement what would I do? If it doesnt hit something what would it do?

I just did a test and it seems the ray is extremely off from where you click. What can to fix that?

Try using Mouse.UnitRay.Direction instead.

Ive tried that but I I get this error


Not on the server script, it has to be in the local script.

1 Like

So ive done that but I still have the same issue

Is there any way to fix it? I dont know what else to do