Ive been trying to fix this issue for the past 4 hours, and I cant get it to work. Thoughts?

Ive been working at this for the past four hours, and I cant get this to work. So here I am.

So I have been working on a game that requires a death screen. So I made one, problem is that it doesn’t work. I have tried finding the player’s health and seeing when it turns to 0, that doesn’t work:

--client side
workspace[game.Players.LocalPlayer.Name].Humanoid:GetPropertyChangedSignal('Health'):Connect(function()
	local health = workspace[game.Players.LocalPlayer.Name].Humanoid.Health
	print(health)
	if health == 0 and workspace.night.Value == true then
		--not important, but works
	elseif health ~= 0 and workspace.night.Value == true and health ~= 100 then
		--not important, but works
	elseif health == 0 and workspace.night.Value == false then
print("does this even work")
--doesnt work, doesn't even print.
end)

Then I tried to use the .Died thing, but that also didn’t work (I deleted the code)

Then I treid to send a remote event thing to the player that has died, but, you guessed it! It also doesn’t work:

Here is the server side script:

status = 'workyouidiot'
remoteeve:FireAllClients(status)

Here is the client side script:

local gameupdate = game.ReplicatedStorage:WaitForChild("update")
gameupdate.OnClientEvent:Connect(function(status)
	if status == 'workyouidiot' then
		print("status")
             --rest of the script
	end
end)

It doesn’t print, or run the rest of the script.

What confused me is the health thing at the top, it works. Even the part that doesn’t work, it works. Only sometimes. It works when the server doesn’t set their health to zero. When a player dies from another player, it works, when a player gets their health set to zero by another script, it works. Just when a player gets their health set to zero by this specific script, it doesn’t work.

Please help

Make sure you’d put end for the conditionals.

--client side
workspace[game.Players.LocalPlayer.Name].Humanoid:GetPropertyChangedSignal('Health'):Connect(function()
	local health = workspace[game.Players.LocalPlayer.Name].Humanoid.Health
	print(health)
	if health == 0 and workspace.night.Value == true then
		--not important, but works
	elseif health ~= 0 and workspace.night.Value == true and health ~= 100 then
		--not important, but works
	elseif health == 0 and workspace.night.Value == false then
        print("does this even work")
        --doesnt work, doesn't even print.
    end
end)

i cut out most of the code since it wasn’t important, and pretty long

local Camera = workspace.CurrentCamera
workspace[game.Players.LocalPlayer.Name].Humanoid:GetPropertyChangedSignal('Health'):Connect(function()
	local health = workspace[game.Players.LocalPlayer.Name].Humanoid.Health
	print(health)
	if health == 0 and workspace.night.Value == true then
		print("health is 0 and its night")
		workspace.sound["deep boom"]:Play()
		script.Parent.Parent.ingamegui.heartbeat:Stop()
		script.Parent.Frame.Visible = true
		script.Parent.Frame.Transparency = 0
		wait(1)
		script.Parent.Parent.mainmenu.Enabled = false--
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable
		Camera.CFrame = workspace.town.cemetary.specialtomb.camera.CFrame
		workspace.town.cemetary.specialtomb.camera.light.Enabled = true
		local t = {"Unknown","One of The Many","Too Curious","Bludgeoned",}
		workspace.town.cemetary.specialtomb.reasontext.SurfaceGui.oof.Text = t[math.random(1,4)]
		workspace.town.cemetary.specialtomb.nametext.SurfaceGui.oof.Text = game.Players.LocalPlayer.Name
		workspace.town.cemetary.specialtomb.datetext.SurfaceGui.oof.Text = "Unknown"
		wait(2)
		for i = 0, 1, .02 do
			script.Parent.Frame.Transparency = i
			wait(.01)
		end
		wait(2)
		for i = 1, 0, -.02 do
			script.Parent.Frame.Transparency = i
			wait(.01)
		end
		workspace.town.cemetary.specialtomb.camera.light.Enabled = false
		workspace.town.cemetary.specialtomb.reasontext.SurfaceGui.oof.Text = ""
		workspace.town.cemetary.specialtomb.nametext.SurfaceGui.oof.Text = ""
		workspace.town.cemetary.specialtomb.datetext.SurfaceGui.oof.Text = ""
		script.Parent.Frame.Transparency = 0
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
			Camera.CFrame = workspace.cameras.CameraPart.CFrame
		until Camera.CameraType == Enum.CameraType.Scriptable and Camera.CFrame == workspace.cameras.CameraPart.CFrame
		for i = 0, 1, .05 do
			script.Parent.Frame.Transparency = i
			wait(.01)
		end
		script.Parent.Frame.Transparency = 1
		script.LocalScript.Disabled = false
		for i, gui in pairs(script.Parent:GetChildren()) do
			if gui:IsA("ScreenGui") then
				gui.Enabled = false
			end
		end
		script.Parent.Parent.mainmenu.Enabled = true
	elseif health ~= 0 and workspace.night.Value == true and health ~= 100 then
		print("health not 0 or 100")
		if debounce == true then
			workspace.sound.jumpscare2:Play()
			debounce = false
			local num = math.random(1,3)
			if num == 1 then
				label.Text = "BEHIND YOU"
			elseif num == 2 then
				label.Text = "RUN"
			elseif num == 3 then
				label.Text = "ITS HERE"
			end
			local num = 0
			while wait(.01) do
				local clone = game.ReplicatedStorage.special:Clone()
				clone.Parent=script.Parent
				num = num + .01
				if num >= .75 then
					script.Parent.TextLabel.Text = ""
					break
				end
			end
			wait(1)
			debounce = true
		end
	else --if health == 0 and workspace.night.Value == false then
		print("else")
		script.Parent.Frame.Transparency = 0
		wait(1)
		repeat wait()
			Camera.CameraType = Enum.CameraType.Scriptable
			Camera.CFrame = workspace.cameras.CameraPart.CFrame
		until Camera.CameraType == Enum.CameraType.Scriptable and Camera.CFrame == workspace.cameras.CameraPart.CFrame
		script.Parent.Parent.mainmenu.Enabled = true
		wait(1)
		for i = 0, 1, .02 do
			script.Parent.Frame.Transparency = i
			wait(.01)
		end
		
	end
end)

there are no errors

You’ll probably rely on a coroutine being there first to hook the event just because of the way blocks are organized

game.Players.PlayerAdded:Connect(function(player)
     player.CharacterAdded:Connect(function(character)
          local aliveconnection
          aliveconnection = character.Humanoid.Died:Connect(function()
               --player died from low health
          aliveconnection:Disconnect()
          end)
          aliveconnection = character.Humanoid.Destroying:Connect(function()
               --player died from deletion like falling off map
          aliveconnection:Disconnect()
          end)   
     end)
end)     

@Spiyder1