✓ Accepted answer
The most basic way of doing this is using the deprecated Hint object:
local Hint = Instance.new("Hint")
Hint.Parent = workspace
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").Died:connect(function()
hint.Text = string.format("%s has died", Player.Name)
end)
end)
end)
However, there are better ways of doing this. Assuming you had the correct hierarchy set up, this would work:
Server
local Event = game:GetService("ReplicatedStorage"):WaitForChild("PlayerDiedEvent")
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").Died:connect(function()
event:FireAllClients(Player)
end)
end)
end)
Client
local Event = game:GetService("ReplicatedStorage"):WaitForChild("PlayerDiedEvent")
local PlayerDiedText = script.Parent
Event.OnClientEvent:connect(function(PlayerWhoDied)
PlayerDiedText.Text = string.format("%s was killed", PlayerWhoDied.Name)
end)
If you want to know more about RemoteEvents, the wiki will be the best place for you to go.
4 comments
Make a gui, clone it into player's playergui when they die.
Please be more specific ( It has to say if ANYONE died, not just the local player)
what I would do is just make a String Value in the workspace(can be somewhere else too) and have it edit that StringValue, then have another script simply edit the GUI from a ".changed:connect" when it first gets changed, make it visible. put in who has died, put in a wait, and after that simply make it go invisible :D
Your print is not finished should be -- print(plr.Name.." was Killed")