How do I script a basic death screen?

It is fired whenever a button is activated. Clicking a button basically make it’s activated. If someone pressed a button mobile, the button would still be activated which is obviously want you want and not just make the UI work on PC only.

So my question now is, what would this all look like put together?

So, you would fire something when the player dies,
You would make a button (Activated:connect(function()
then you would load the character.

In lua form? Sorry for being kinda annoying.

can you please show your script, also connect is deprecated, use Connect

The script I used was this but it didn’t work. It was made by Ulxqra.

humanoid.Died:Connect(function()
script.Parent.Frame.Visible = true --Where ever your frame is.
end)
wait(3)
script.Parent.MouseButton1down:Connect(function()
player:LoadCharacter()
script.Parent.Frame.Visible = false – Gui goes off
end)

You haven’t defined what player is.

I really don’t know how to script much, I just started learning and I don’t really understand much.

I scripted an Intro for my game and a couple other things but those were simpler.

Would local player = game.Player.LocalPlayer work?

https://devforum.roblox.com/t/deadmessage-gui-its-that-simple/688889/6?u=kylerzong

Script In ServerScriptService

local Remote = Instance.new("RemoteEvent", game.ReplicatedStorage)
Remote.Name = "RespawnRemote"


Remote.OnServerEvent:Connect(function(plyr)
	plyr:LoadCharacter()
end)

Localscript in StarterPlayerScripts

local Player = game.Players.LocalPlayer
local PlaySoundOnSpawn = true
local SpawnSound = "rbxassetid://134012322"
local ShowGuiOnDeath = true
local PlaySoundOnDeath = true
local DeathSound = "rbxassetid://157636218"


local OldGui = nil
Player.CharacterAdded:Connect(function(character)
	if OldGui then OldGui:Destroy() end
	if PlaySoundOnSpawn then
		local Sound = Instance.new("Sound")
		Sound.SoundId = SpawnSound
		Sound.Volume = 2
		game:GetService("SoundService"):PlayLocalSound(Sound)
		game:GetService("Debris"):AddItem(Sound, Sound.TimeLength)
	end
	character:WaitForChild("Humanoid", math.huge).Died:Connect(function()
		if PlaySoundOnSpawn then
			local Sound = Instance.new("Sound")
			Sound.SoundId = DeathSound
			Sound.Volume = 2
			game:GetService("SoundService"):PlayLocalSound(Sound)
			game:GetService("Debris"):AddItem(Sound, Sound.TimeLength)
		end
		local Gui = Instance.new("ScreenGui", Player.PlayerGui)
		Gui.IgnoreGuiInset = true
		local Frame = Instance.new("Frame", Gui)
		Frame.Size = UDim2.fromScale(1,1)
		Frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
		Frame.BackgroundTransparency = 0.7
		local TextLabel = Instance.new("TextLabel", Frame)
		TextLabel.Size = UDim2.fromScale(0.1,0.15)
		TextLabel.Text = "Dead"
		TextLabel.Font = "Arial"
		TextLabel.BackgroundTransparency = 1
		TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
		TextLabel.TextScaled = true
		TextLabel.Position = UDim2.fromScale(0.5 - TextLabel.Size.Width.Scale/2, 0.5 - TextLabel.Size.Height.Scale/2)
		
		
		local TextButton = Instance.new("TextButton", Frame)
		TextButton.Size = UDim2.fromScale(0.1,0.15)
		TextButton.Text = "Respawn"
		TextButton.Font = "Arial"
		TextButton.BackgroundTransparency = 0.6
		TextButton.BackgroundColor3 = Color3.fromRGB(0,0,0)
		TextButton.TextColor3 = Color3.fromRGB(255,0,0)
		TextButton.TextScaled = true
		TextButton.Position = UDim2.fromScale(0.5 - TextLabel.Size.Width.Scale/2, 0.5 - TextLabel.Size.Height.Scale/2) + UDim2.new(0,0,0,200)
		
		
		local RespawnRemote = game.ReplicatedStorage:WaitForChild("RespawnRemote")
		TextButton.MouseButton1Down:Connect(function()
			RespawnRemote:FireServer()
		end)
	end)
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)

char.Humanoid.Died:Connect(function()
   plr.PlayerGui.GUINAME.Enabled = true 
   wait(3)
   plr.PlayerGui.GUINAME.Enabled = false
end)

end)
end)

just do something like this

But you see it needs to have a respawn button.

I just made a simple and quick system right now and I’ll release my scripts on how I did it, here it is:
Make sure to add RemoteEvent inside of ReplicatedStorage you can change name if you want but make sure that you also do inside scripts.

Script in ServerScriptService:

local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent",4)


game:GetService('Players').PlayerAdded:Connect(function(player)
    game:GetService("Players").CharacterAutoLoads = true
	player.CharacterAdded:Connect(function(character)
		game:GetService("Players").CharacterAutoLoads = false
		character:WaitForChild("Humanoid").Died:Connect(function()
            --Change here location to your dead screen frame or button as I did.
			player.PlayerGui:FindFirstChild("DeadScreen"):FindFirstChild("TextButton").Visible = true
		end)
	end)
end)

Event.OnServerEvent:Connect(function(player)
	player:LoadCharacter()
end)

LocalScript inside of a button for reset character:

local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent",4)

script.Parent.MouseButton1Down:Connect(function()
    Event:FireServer()
end)
1 Like

02:06:24.904 - ServerScriptService.Script:9: attempt to index nil with ‘Visible’ Was the error I got from those scripts.

Did you change locations inside script based on your explorer location and names?

I’m a little big confused. I changed the names to the stuff they needed to like the DeathScreen I changed and a couple other things.

Yet nothing happens when I die.

Send me a picture of your explorer, please.

Just a simple picture of the explorer?