Hello there! I’m having a small issue with this script. It’s supposed to pick a random message out of a table, and display it to the player when they die. The issue is, it only runs once. If the player dies one time, everything appears to work fine. If they die a second time, nothing happens. No errors either. It only works one time, then completely stops. Some help on how to fix this would be very appreciated Note: “script.Parent” is referring a TextLabel, of which this script is a child of.
local deathMessages = {
"OOF",
"Wow, you suck.",
"Really..",
"Ouch",
"Goodbye",
"That looked painful.",
"Glad i'm not you.",
"Zoinks",
"Mistakes were made..",
"You died.",
"Good job, buddy."
}
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local random = math.random(1, #deathMessages)
script.Parent.Text = deathMessages[random]
script.Parent.Visible = true
wait(6)
script.Parent.Visible = false
end)
if it had anything to do with the character, the script wouldn’t work entirely, because it’s checking to see if the Humanoid died, which is part of the character. As you already read in the original post, It only shows the message once, and then never shows it again. No errors. Just doesn’t show again, with no explanation. So if it shows once, that means it found the character successfully. I’m completely stumped.
Oh! I know, when the character dies, then it’s a new character generated for that player, so that died character’s parent is nil, so removed the line. Player.Character, only put Player.CharacterAdded:Wait()