Death Message Script Help Needed

Yes… Obviously. ------------------------

Hm, what type of script are you using, and what is its parent.

I did exactly what they said, local script in startercharacterscripts.

robloxapp-20200520-2036110.wmv (2.2 MB)

These are my results using the code I have in my OP.

Are there any errors in the out put

you should probably add a wait

on the while loop

You shouldn’t use a loop for this to begin with. Events exist for a reason.

Take a look.

He would make the text appear on an event when the humanoid died or the player

not a while loop

Alright thanks for providing me a website that allows me to do this. Except there is no requirement for me to use extra programs for recording

Thats literally what @xZylter proposed.

remember this code?

local DeathMessages = {"Death Message 1","Death Message 2","Death Message 3"}

local LOCAL_PLAYER = game:GetService("Players").LocalPlayer

LOCAL_PLAYER.CharacterAdded:Connect(function(Character)
	Character:WaitForChild("Humanoid").Died:Connect(function()
		LOCAL_PLAYER.PlayerGui.ScreenGui.Enabled = true
LOCAL_PLAYER.PlayerGui.ScreenGui.TextLabel.Text = DeathMessages[math.random(1,#DeathMessages)]
		
	end)
end)

make sure you make this visible before you set it

It would work in both ways… The ScreenGui doesn’t needs to be Enabled for you to change its properties.

Still doesn’t work. ----------------------

Can you send us images of the properties of the ScreenGUI and TextLabel?

1 Like

Sure ----------------------------------

Its descendants too, more likely.

1

Adding to @xZylter’s code:

local DeathMessages = {"Death Message 1","Death Message 2","Death Message 3"}
local Connection --> It will let us manage better out RbxScriptSignal

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer



--> Will dispare every time a new character is added to Player.Character
LocalPlayer.CharacterAdded:Connect(function(Character)
	local ScreenGui = LocalPlayer.PlayerGui:WaitForChild("ScreenGui")

	--> Here we can save our RbxScriptSignal to Disconnect it later
	Connection = Character:WaitForChild("Humanoid").Died:Connect(function()
		ScreenGui.TextLabel.Text = DeathMessages[math.random(1, #DeathMessages)]
		ScreenGui.Enabled = true
		
		--> Turning all descendants of ScreenGui to Visible = true
		for _, Object in pairs(ScreenGui:GetDescendants()) do
			if Object:IsA("GuiBase") then
				Object.Visible = true
			end
		end

		--> Let's disconnect the function now?
		Connection:Disconnect()
	end)
end)

Added a :Disconnect to avoid Untracked Memory, and turned all descendants of ScreenGui to Visible = true, just for sure.

4 Likes

Pretty weird, i actually used xZylter’s code and it worked just fine!

Don’t mind the tools…

I think your script has an error with the Connection.

Nevermind I used your script before the edit