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

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")
   plr.CharacterAdded:connect(function(chr)
      chr:WaitForChild("Humanoid").Died:connect(function()
         print(plr.Name .. " was killed
      end)
   end)
end)

4 comments

0

Make a gui, clone it into player's playergui when they die.

0

Please be more specific ( It has to say if ANYONE died, not just the local player)

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

0

Your print is not finished should be -- print(plr.Name.." was Killed")

1 answer

✓ 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) -- 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")
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) -- 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.

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