0

# How do I make text Appear when a Player dies? (Not Print function)

How do I make this text appear as a Gui?

game.PlayersPlayerAdded:connect(function(plr)
print(plr.Name .. " has Joined the game")
chr:WaitForChild("Humanoid").Died:connect(function()
print(plr.Name .. " was killed
end)
end)
end)


0
Make a gui, clone it into player's playergui when they die. Goulstem 8144 — 7y
0
Please be more specific ( It has to say if ANYONE died, not just the local player) Seeker5123 15 — 7y
0
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 lomo0987 250 — 7y
0
Your print is not finished should be -- print(plr.Name.." was Killed") woodengop 1134 — 7y

0
digpoe 65
7 years ago

The most basic way of doing this is using the deprecated Hint object:

local Hint = Instance.new("Hint")
Hint.Parent = workspace

Character:WaitForChild("Humanoid").Died:connect(function()
hint.Text = string.format("%s has died", Player.Name) -- I prefer using string.format, so I will use this.
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")
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) -- Again, I prefer string.format, so I will use this.
end)


If you want to know more about RemoteEvents, the wiki will be the best place for you to go.