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