How do I get a weapon's name whenever someone died by that person's weapon they're holding.
(Replicated Storage)
local event = game.ReplicatedStorage.TheyDiedLol game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char:WaitForChild("Humanoid").Died:connect(function(killed) local killer = char.Humanoid:FindFirstChild("creator") if killer.Value then local killerName = killer.Value.Name event:FireAllClients(plr, killerName) end end) end) end)
If it's a tool, what you could easily do is:
(for the local script assuming it is)
game.ReplicatedStorage.TheyDiedLol.OnClientEvent:Connect(function(Player, plr, killer) local playerKiller = game:GetService("Players"):FindFirstChild(killer) --find the player using the killer name if playerKiller then --check if the player still exists or is still in the game or not local weapon = playerKiller.Character:FindFirstChildWhichIsA:("Tool") --finds a child of the killer's character and makes sure it's a tool if weapon ~= nil then --obviously checks if it still exists or not local weaponName = weapon:GetFullName() --gets the full name --now you have the weapon name, and maybe you could send it in as a weapon. end end end)
If you don't know already, tools only appear in the player's character only if they have it equipped. But if they don't have it equipped then it will only remain in their backpack. With that being said, if it's a tool (which I hope it is) then you can get the tool's name using this method, which will fire as soon as possible when the specified player's (not the killer) humanoid dies. You can then proceed to set this into a value.