Can rays be cast locally?

As the title says, I’m wondering if rays can be cast from a local script while still being able to hit other players.

No they cannot. Your best option is server for what your trying to achieve.

Ah I see
Then would it work to get the locations from a local script and fire it from the server?

Pretty much, you can let the server handle the sanity checks, and the client handle the Position from where the Ray was first cast

Just make sure not to rely on the client too much

Yeah, I had a previous model where all the rays were cast from the server, which were used for player hitboxes.
I wanted a portion of it handled by the client in that the rays would be accurate from the player’s position on their client.

NEVER TRUST THE CLIENT.

That’s how you get your game exploited. Always let the server handle all checks to make sure a client isn’t exploiting to shoot through walls or anything.

2 Likes

You can cast rays from the client. It’s no different from the server except it’s not run on the server(therefore wont replicate).

@kndn_v sometimes it’s necessary to do some things on the client. Having server sided checks are only necessary for data that shouldn’t be tapered with, such as player data.

7 Likes