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.
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.
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?
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 (:
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?
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).