Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Hey does anyone know how to make a "you were killed by [player Name]" script?

hi do you know how to make a script that when the player dies by someone it says "you have been slain by ...[player Name]"?

3 comments

0

game.Players.LocalPlayer.Name

0

^^ Not correct, this will tell your name, in order to do what he wants you would need a sort of 'tag' system

0

so if i used this in like a textlable or a gui in genera i will say the death msg?

1 answer

Lets say you have a gun script. We can fire an if statement to see if the player died.

local Name = game.Players.LocalPlayer
local HitPlayer = hit.Parent.Name

if hit.Parent.Humanoid.Health <=0 then
	print(HitPlayer .. "was slain by" .. Name .. ".")
end

or we can run a function

local Name = game.Players.LocalPlayer
local HitPlayer = hit.Parent.Name


function PlayerDied()
	print(HitPlayer .. "was slain by" .. Name .. ".")
end

hit.Parent.Humanoid.Died:connect(PlayerDied)

Im referencing hit.Parent as the model that the raycast/bullet hits. If you want to change this to something like a sword just make hit.Parent the model that touches the sword/blade. Problem with the if statement is that if you shoot the DEAD body it will still print this into the output.

This discussion is preserved as it was. New answers, comments, and votes are closed.