I’ve recently made an OTS gun system. Looks good so far, now I’m into making the raycast stuff though I’m not really experienced with anything raycast-wise.
Here’s my current setup.
What I basically want to do is to have my racast origin the gun, and my Raycast direction the GUI frame. Any way I could do that? Thanks.
You could try using the function which is called “WorldToScreenPoint”
https://developer.roblox.com/en-us/api-reference/function/Camera/WorldToScreenPoint
There’s a few steps here.
- ScreenPointToRay your gui
- Extend the ray
- Cast it to figure out what part the gui is hovering over
- Cast a different ray from the gun position to the gui hover position to do the shot
2 Likes