Hi there, I was wondering how I would get the cause of a death, for example, Player died because they fell 60 studs or something like that.
Thanks in advance.
Normally in fighting games there is a sort of tagging system where each weapon hit would apply a tag to the player usually containing data such as the attacking player and the weapon used, so the server can send messages like “[Player_A] killed [Player_B] with [Weapon]”.
If you are using this method then you would just modify your fall damage script to apply its own tag when players get hurt that way.
1 Like
Also you can send a Remote Event to give info on how you died.
local Death
local How = -- way you died (This would be in a fall damage script and just say if ..humanoid.Health = 0 then fireClient, etc.. make sure how is a string value like "Fall Damage"
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
Death = ["Death by" .. How]
RemoteEvent:FireClient(Player, Death)
LocalScript
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local function Died(Death)
game.Players.LocalPlayer.PlayerGui.Text = Death
end
RemoteEvent.OnClientEvent:Connect(Died)
personally i would have a string value inside the player that changes depending on the last damage source it recieved, and then work from there