Hello! I am trying to figure out how to make an image pop up on a players screen when they have died. Kind of like in GTA when you die it says "WASTED". I need the script to be inserted into the player for it to work I think. Thank you!
~Minikitkat
More than likely, the script would have to be inserted into your character. To do this, make your GUI and set the Visible property to false. Then, you will need a server script in ServerScriptService (preferably) with the following code:
function onPlayerEntered(player) -- "Player" as argument repeat wait() until player.Character ~= nil -- Makes sure the character finished rendering local Wasted = script.LocalScript:clone() -- Sets a variable to your script Wasted.Parent = player.Character -- Places the script in the character Wasted.Disabled = false -- Enables the script player.CharacterAdded:connect(function (char) -- Every time the character spawns, this will happen to it; "char' as argument repeat wait() until char ~= nil -- Makes sure the character finished rendering; not really necessary, but better safe than sorry? local Wasted = script.LocalScript:clone() -- Sets a variable to your script Wasted.Parent = char -- Places the script in the character Wasted.Disabled = false -- Enables the script end) end game.Players.PlayerAdded:connect(onPlayerEntered) -- When player enters, the assigned function will be triggered
Then insert a LocalScript in the aforementioned script, disable it, and add something like this:
s = script.Parent s.Humanoid.Died:connect(function () -- If your humanoid died, this is triggered game.Players.LocalPlayer.PlayerGui.WastedGUI.Frame.Visible = true -- Assuming that your GUI's name is "WastedGUI" & its descendant is a Frame end)
If you want to add a little twist, you can add a Sound object in your Gui, then add the code to play the audio in your LocalScript. :P