#Issue with gui displaying on death

1 messages · Page 1 of 1 (latest)

toxic quartz
#

I am working to make it so when you die your screen displays a message. For some reason it only displays the message once but still does the blur and red effects every time.

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("UI").DeathBroadcastUI

local lighting = game:WaitForChild("Lighting")
local blur = lighting:WaitForChild("DeathMessageBlur")
local redColor = lighting:WaitForChild("DeathMessageRed")

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local screengui = playerGui:WaitForChild("DeathMessage")
local text = playerGui:WaitForChild("DeathMessage").DeathText

local ring = game:WaitForChild("SoundService").DeathRing

local messages = {
    "Pro tip: Don’t fall",
    "Don’t blame ur wi-Fi it’s just you bro🥀💔",
    "Go outside and get a j*b",
    "dw I believe in you",
    "Tip: The harder you slap the farther they fling",
    "Dont quit now soldier"
}

event.OnClientEvent:Connect(function()
    print("DeathBroadcast event received")
    screengui.Enabled = true
    blur.Enabled = true
    redColor.Enabled = true

    local msgText = messages[math.random(1, #messages)]
    local message = msgText
    print("Showing message:", message)
    text.Text = message
    ring:Play()

    task.wait(3)

    screengui.Enabled = false
    blur.Enabled = false
    redColor.Enabled = false

    text.Text = "label"
end)

I added a print statement in and it correctly shows what the random message would have been. The ring sfx plays and everything resets. Its just not displaying the text for a second time