Help with logic behind a third person gun/tool script using raycasting

So basically you are trying to say I would cast a ray on the client, if it hit a humanoid, send that to the server and then shoot a ray from the player’s position to the position of the humanoid they hit on the client and make sure that’s correct?

You’re right, sticking to a ray will be much better! Thank you for those threads they are really helpful at giving me ideas!

Yeah, You basically raycast from Client and then Give the Server TargetPosition and PlayerPosition Create 2 Parts out of those Target and player Pos make sure it got ignored by Gun’s Raycast, and make the current Server Raycast ignore every humanoid character and then check if it hit a part or not, If it does register the damage

u should make the Ray on Server becouse on Server all the Clients can see the bullet, if u make it on the Client only the Client can see the bullet

You could just send the info to RemoteEvent and then make a function to make a bullet on the server.

The server is the one dealing the damage and verifying the information. But the client is only doing visual stuff and figuring out what you are shooting at. So I would have to agree with them that a half-way solution is best.

Exactly, that’s what I’m going to do as well.

that will be much harder to Handle if u not make the Ray on Server

Well it’s better than having to estimate player’s movement in term of gameplay.

1 Like

How so? All I need to use is a RemoteEvent and pass the data to the server. Quite simple actually.

Have you played The Street before? You will get that feeling when you try to melee or shoot someone

if u put on Client u need more things, a remote in ReplicatedStorage so all players can see the bullet, then sending in another remote Event in ReplicatedStorage to see the Ray’s end CFrame and if the Ray hit something and the LookVector of the Ray and will be much harder becouse u will not able to see Ray’s Origin and more

To be honest, this is what most FPS programmer would do, Put Hit detection on Client so hitboxes would be better compare to server. we hate having Server hitboxes don’t we?

1 Like

Have not, but I know what you’re talking about for sure. Anyways I still need to figure out how to cast that ray in the proper direction on the client. So once I try out @Jaycbee05 's viewport idea i’ll get back to you. Thanks a lot guys

Okay, Goodbye. My job is finished I believe

for the aiming part, you will want to make the character face the mouse position. EgoMoose has a tutorial for that aspect, along with other gun-related info, here. it is oriented towards first person though

when you have the character facing the mouse position, you will raycast out from either the LookVector of the tip of the gun or the LookVector of the torso.

He said Third person and that’s first person

Nice method but only for first person, as doing it this method would leave me with an incredibly inaccurate way to cast a ray, since it wouldn’t be shooting at all towards where you are aiming with your crosshair

im confused as to how thats the case. when you change your camera direction, it changes the gun direction, which changes the ray direction. + its more accurate than firing from the camera since its exactly where the gun is pointing and where the bullet is coming from.

dada

simpler for me to explain this way

i also think the first method given is probably at lot simpler… I’ll have to figure out if it’s what I wanted tho