Need help with RayCast

how to make it so that if the player looks or an object appears on the screen, then you need to deal damage?

1 Like

You don’t need raycast for that, you can just use :WorldToViewportPoint(). It returns whether a point is on the screen (next to where it is on the screen).

And can you explain how it works?

It uses math to calculate:

(what I said and linked to)

it’s not for me that if see there is a model part or a meshpart, then damage must be done

Next time you should look through the forum better, this has already been asked:


Using :WorldToViewportPoint() or :WorldToScreenPoint() is the only way. The answer to the above post also uses :GetPartsObscuringTarget() to see if there are any parts in the way.


The limit of this is that large parts might result in false negatives (because then you can see the edges but not the center which is used in :WorldToViewportPoint()) and false positives with transparent parts like described in the solution.