FindPartOnRay returns nill

Can someone please tell me why this is returning nil.


the part on ray returns nil for some reason even though it should be htting the players character

solution:


you really dont need the 750 but just to make sure it goes through the player i put that

Rays are constructed with two arguments, the Origin (where to start the ray from) and a direction, you are trying to use the direction property as an endpoint, which won’t work.

2 Likes

Did you make sure that the if statement isn’t passing? You have it set to return nil there if it passes.

yes the if’s all work

I really don’t get what you mean. Isn’t the second argument where you want it to point to

I got what you meant thanks

It’s the direction of the ray, away from the first position argument.

1 Like

Your direction argument says

HumanoidRootPart.Position * 10

you cannot mutiply vector3’s by a number value for the purpose of finding a direction; it just wont work like that

so instead do this

 HumanoidRootPart.CFrame.LookVector * 10 --this will take the forward facing vector of the part's cframe and go 10 studs along it

this should fix your issues

You can multiply a Vector3 by a number value


Even though the question was already answered, can you post the solution so that others can see?

Thanks for the clarification, I made an edit

1 Like

you can multiply vectors

the original statement was a bit vague, I clarified.

1 Like