Making a Death Screen for my game

Hello my Fellow Developers!

Does anybody of you know how to make a Death Screen like Doors? Like when you die, You spectate a last player and you get choices like you spend 50 Robux for Revive or Go back to lobby.

And before showing the Spectate and Revive GUI they’ll get a GUI saying some advices to avoid the entities, Does anybody know how to do that?

3 Likes

I actually made this before.
deathcamera.rbxm (5.7 KB)
I suggest you review the code for it. It’s quite outdated and you’d be better off remaking it.

But it’s good learning material.


The revival would be hard to do since you’d essentially have to replace the dead humanoid and insert a new one. The GUI itself shouldn’t be too hard to make.

1 Like

Does it have a Fading System? Like The Death Screen will fade away and then the Spectating Gui will be Visible.

1 Like

No, it doesn’t. There’s nothing stopping you from adding that. Like I said, I provided it for learning material.

1 Like

By the way @SubtotalAnt8185 do you know how to make a Crouching system?

And the First person’s view will be lowered if you crouch? Pressing Letter ‘C’?

1 Like

I tried every Roblox Video Tutorials, It just wouldn’t work…

or just refresh the player with Player:LoadCharacter() ?
i feel like this way is more easy.

1 Like

You need contextaction service and for the player to play and Animation. I recommend looking it up. It wouldn’t be that hard though. You need animations for crouch walking and crouching, make a boolean, get contextactionservice, and toggle it.

I haven’t done the spectate before, but for the death screen itself, you need to use a ScreenGui and an event handler for the humanoid. From the client…

local playerService = game:GetService("Players")
local localPlayer = playerService.LocalPlayer
local character = localPlayer.Character
local human = character:WaitForChild("Humanoid", 10)

local function showDeathScreen()
	local playerGui = localPlayer:WaitForChild("PlayerGui", 10)
	if playerGui ~= nil then
		local deathGui = playerGui:WaitForChild("DeathGui", 10)
		if deathGui then
			local deathFrame = deathGui:WaitForChild("DeathFrame", 10)
			if deathFrame then
				-- Enable any text and image elements here
				textLabel = deathFrame:WaitForChild("TextLabel", 10)
				if textLabel ~= nil then
					textLabel.Visible = true
				end
				imageLabel = deathFrame:WaitForChild("ImageLabel", 10)
				if imageLabel ~= nil
					imageLabel.Visible = true
				end
				-- Enable the GUI and the frame last.
				deathGui.Enabled = true
				deathFrame.Visible = true
			end
		end
	end
end

-- And this is probably the part that you are missing...
human.Died:Connect(function()
	showDeathScreen()
end)

How does this work?

You need to create the death screen. The function that I wrote, showDeathScreen() is an example with example names of the various ScreenGui’s, frames, text labels, image labels, etc… You need to create the hierarchy in game.StarterGui. When the player dies, the Humanoid.Died event is fired. In the event handler, we call the death screen function. This implementation is purely client sided. You can implement a server side version that uses a remote event to tell the client to activate the death screen (This is what I did in my game.). You can place the script in game.StarterPlayer.StarterPlayerScripts. If you are going to use this script, then you need to change the names to suit your environment.

Where do i put the script? (character limit)

Um… I mentioned that in my post…

game.StarterPlayer.StarterPlayerScripts

1 Like

Oof,Maybe I didn’t have time to read it :sweat_smile:

How can I add advices to text once player dies?

Like if player dies they get an Advice to avoid the entity

And the player dies again. They’ll get another Advice or any tips

replace human.Died with this:

human.Died:Connect(showDeathScreen)

or the entire code (specifically this chunk of code) just this

local playerService = game:GetService('Players') or game:FindService('Players')
local localPlayer = playerService.LocalPlayer
local character = localPlayer.Character
local human = character:WaitForChild('Humanoid', 10)
human.Died:Connect(function()
	local playerGui = localPlayer:WaitForChild("PlayerGui", 10)
	if playerGui then
		local deathGui = playerGui:WaitForChild("DeathGui", 10)
		if deathGui then
			local deathFrame = deathGui:WaitForChild("DeathFrame", 10)
			if deathFrame then
				-- Enable any text and image elements here
				textLabel = deathFrame:WaitForChild("TextLabel", 10)
				if textLabel then
					textLabel.Visible = true
				end
				imageLabel = deathFrame:WaitForChild("ImageLabel", 10)
				if imageLabel then
					imageLabel.Visible = true
				end
				-- Enable the GUI and the frame last.
				deathGui.Enabled = true
				deathFrame.Visible = true
			end
		end
	end
end

Um… No.

This is specifically coding style. I have my own style when I code. My way, I know what’s going on, what parameters are passed, etc… Using your format, I can’t tell what’s being passed until I look at the function definition. If you look through my code, I actually specify the parameters in the function definition of the event handler. Here’s an example:

playerService = game:GetService("Players")

local function initializePlayer(player)
	-- Do something
end

playerService.PlayerAdded:Connect(function(player)
	intializePlayer(player)
end)

Granted, your version is less code, but my version is more readable. Professional system software engineer and such.

Do you know how to make a system like you purchase 50 Robux to revive? Like Doors.

It sounds like all you do is ask for help or watch tutorials

1 Like

Nevermind, I figured it out. I found something on YT

YES! IT WORKED!! Even my friend CalypsoGames (A.K.A = Calico, The owner of MagicalGames) was impressed

robloxapp-20220924-2127142.wmv (3.0 MB)

So sorry if the Video is bad quality, I just used the Roblox Default one, Because i’m in a hurry. I was going to Mall.