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