[SOLVED] GUI not visible when Humanoid dies

When the Humanoid dies, the GUI should be visible; It’s not working though.

The code:

local plrs = game:GetService("Players")
local DeathT = script.Parent:WaitForChild("Death")
local plr = plrs.LocalPlayer or plrs.PlayerAdded:Wait()

local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(3)

local tween = TweenService:Create(DeathT,tweenInfo,{["BackgroundTransparency"] = 0, ["TextTransparency"] = 0})
local tween2 = TweenService:Create(DeathT,tweenInfo,{["BackgroundTransparency"] = 1, ["TextTransparency"] = 1})
plr.CharacterAdded:Connect(function(chr)
	
	local hum = chr:WaitForChild("Humanoid")
	
	hum.Died:Connect(function()
		
		tween:Play()
		
		DeathT.Text = plr.Name .. " has died."
		
		task.wait(4)
		
		tween2:Play()
	end)
	
end)

Any help is hugely appreciated because I’m really bad at coding.

1 Like

This is a server-side script, right?
forget the above,

1 Like

Client-sided script in the ScreenGui.

Are you sure that the Gui is enabled?

Yes
image_2023-01-08_192725318

I’m assuming that you know that the character could be already be added before the CharacterAdded event being connected.

Does the humanoid’s Died event fire?

That worked. I removed the CharacterAdded function and made a character variable and it worked.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.