✓ Accepted answer
(This answer only applies if you have FilteringEnabled on; you can check it by looking in the Properties window with the Workspace selected.)
The default behaviour is for the player to die when their health reaches 0. Assuming you haven't changed that (and haven't changed the health system and haven't changed the player's default model), then what you're describing is what one would expect if your weapons you're using were not designed for FilteringEnabled -- that is, they attempt to hurt the player's Health directly. This causes their health drain to be only visible to you. To fix this, you have to have the server run the health drain code instead of the client. A very insecure method is to have a RemoteEvent that lets any client tell the server who they hit and how much damage they caused. Do note that scripting it like this is the easiest route, with the drawback that any exploiter will be able to kill everyone else in the server instantly and repeatedly (though you can add checks to limit this, if you know how). An even more insecure method is to disable FilteringEnabled (granting exploiters free reign), but at least your game would be playable if you just invite a few trusted friends into it.
Edit: Here's the insecure method. In every weapon, find where it damages the player and instead fire a RemoteEvent that you have placed in game.ReplicatedStorage named "DamagePlayer"
hum:TakeDamage(5)
hum.Health = hum.Health - 5
game.ReplicatedStorage.DamagePlayer:FireServer(hum, 5)
game.ReplicatedStorage.DamagePlayer.OnServerEvent:Connect(function(player, humanoid, damage)
if not humanoid then return end
if type(damage) ~= "number" or damage < 0 or damage > 100 then return end
humanoid:TakeDamage(damage)
end)
A superior method (requires more scripting skills) is the client telling the server the weapon used and the angle it was fired at; the server can then determine if any damage should be applied to anyone. Note that this is still weak to aim-bots, but at least exploiters wouldn't be able to kill people through walls.
9 comments
Yes, I have filtering enabled. I am simply not able to understand any of the solutions you gave because of my inexperience. However, you said the weapons are not compatible to filtering enabled, thus makes it so the player cannot die? To fix this, could I just remove all weapons from the game?
If you remove all your weapons, you won't have any malfunctioning weapons, but then you won't have any way of attacking other players, right? Try reading http://wiki.roblox.com/index.php?title=Experimental_Mode and http://wiki.roblox.com/index.php?title=Converting_Experimental_Mode_Games .
I have edited my answer with an example of one of the solutions I mentioned
I have tried to do your solution on the "Raycast Assault Rifle" by TravellingElectron. I tried it on other guns as well. It does not work still. Could you please show me how it is done on the Raycast Assault Rifle?
It doesnt have to be the Raycast Assault Rifle, it can be any gun it doesn't matter. Thanks!
It works for me. I have done as you requested. I didn't test it Online, but I believe the "Start Server" test I performed (with 2 players) was sufficient. I've uploaded the model (you should be able to find it in my inventory).
I got it, and found I was doing something wrong. Thanks for all your help bro
I got it, and found I was doing something wrong. Thanks for all your help bro
Glad you figured it out =)