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

How to place a GUI in a Player's PlayerGui once a player has died?

CharacterAutoLoad is set to false.

function onPlayerDied(player)
	script.StartMenu:Clone().Parent=game.Players.LocalPlayer.PlayerGui
end

Players.LocalPlayer.Character.Humanoid.Died():connect(onPlayerDied)

I keep getting this error:

13:58:09.416 - ReplicatedFirst.GUI:22: attempt to index field 'Character' (a nil value)

Thank you!

2 answers

✓ Accepted answer

Put this in Normal Script in workspace and put the Gui In it and name the GUI dead

function udead(whodat, whodatplr)
	whodat.Humanoid.Died:connect(function()
		script.dead:Clone().Parent = whodatplr.PlayerGui
	end)
end

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:wait()
	udead(plr.Character,plr)
	plr.CharacterAdded:connect(function(char)
		udead(char,plr)
	end)
end)

1 comment

0

you don't need lines 2, 4, 8, 9

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