Players Do Not Die When Shot

Hello,

In my game people can no longer die. If you shoot somebody to death the person will appear dead on your screen but the player will not actually die from the perspective of the player who was shot (nor will they take any damage).

This has happened before and the only thing I was able to do was to rebuild the entire game from scratch. Now it has happened again and I am wondering if anybody can help. I will start making the game over again if necessary but I would like to figure out how to avoid this in the future.

Thank you very much!

3 Likes

This is due to FilteringEnabled I’m assuming. This might help you:

Anything done in a local script is only viewable by the client that localscript is owned by; i.e. The player who fired the gun. To make it kill the other player you’ll need to fire a RemoteEvent or invoke a RemoteFunction to the server, (then do serverside checks to ensure it’s a valid shot, although this is advised, it’s not compulsory), then in a Script you’ll need to kill the player.

5 Likes

Thank you very much for your quick reply. I have recently learned about Remote Events and Functions, but here is why I am confused. The gun I am using if from Roblox’s Raycasting Tutorial and I have used it before many times (always as a localscript inside a tool) and it has almost always worked on the server (about 90% of the time). For some reason, on this current game, it no longer works and I cannot figure out why.

Regardless to set up a Remote Event in this fashion I would pass through the target player and the damage to be done correct?

Thank you!

Experimental mode (AKA games without FE) recently got removed. Your games now have to be FE. That’s why it used to work, but doesn’t anymore.


Yeah, you could do it that, however you should follow the ‘rules’ of making your game not exploitable and handle all of that on the server (otherwise an exploiter could just spam the RemoteEvent on whichever player they want with 10000000 damage and instakill them and anyone else). It is a bit complicated for a beginner, though, so at this stage just do that if you don’t want to need to learn lots of stuff (:

3 Likes

Thank you and everybody so much! I really really appreciate all the help!!

I was aware that Roblox had made those changes, but I stupidly thought that toolscripts were somehow exempt (it doesn’t make sense I know LOL). I have noticed that localscripts can play sounds which will be heard throughout other players, is that correct?

In the LocalScript I have the damage calculated based on the distance of the target from the tool handle; how would I do this so it is calculated on the server and is therefore protected from exploiters? One idea is to just send the distance to the server and have the server calculate the damage, but it could still be hacked I think if somebody knew to just change the distance to a lesser value. Lastly, if the part that is hit of the humanoid is titled “Head” or “Face” it deals 100 damage. Is there a risk of a player exploiting the localscript and changing it to say that they hit a player’s head when they didn’t?

Thank you very very much to you and everybody!

4 Likes

I believe there is a property in SoundService which you can toggle this behavior for. RespectsFilteringEnabled or something like that. Also note that clients with ‘ownership’ of something (e.g. their character) can make changes (play an animation, create a sound, etc.) and have them replicated to the server.


Calculate the distance on the server then! (e.g. use their character’s root position and their target’s root position.) Note that since players have ‘ownership’ of their character, they are able to move their character around to wherever they want with exploits, so you’ll need to manually check for that if you think it’s gonna be an issue.


Same problem; same solution – check to see what was hit on the server instead of the client. However, this will also mean lag will be really annoying for your players. For better player experiences, check it on both the server and the client, so that the player’s shooting isn’t crippled by lag. You’d send what the client thinks it hit to the server, and the server would then verify that (for example, by checking to see if the hit position was within x distance to the current position of the target, x being big enough to compensate for the short lag between the player shooting and receiving the target’s new position and stuff and then the same again for sending the hit to the server).

6 Likes

You rock! Thank you so much for helping a new dev like me and for such a helpful post!

2 Likes