My code won't function right

Hi there,

  1. My code is not working for a odd reason?

  2. Im trying to make it so when u reset the remote event fires or when u die but it isnt working

  3. I tried using findfirstchild and hum.health or hum.died and still didnt work

The code is down below i need help solving the 2nd paragraph thanks!

local MarketPlaceService = game:GetService("MarketplaceService")

local ID = 13442992

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, ID) then
			game.ReplicatedStorage.GiveHalo:FireClient(Player)
			
		end
	end)
end)

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local hum = Character:WaitForChild("Humanoid")
		if hum.Health == 0 then
			wait(1)
			game.ReplicatedStorage.GiveHalo:FireClient(Player)
		end
	end)
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

You can put the 2 sections in the same event block isntead of making duplicate events.

Your main issue is that you’re checking the health once, there’s an event that does exactly what you need, the Died event

local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ID = 13442992

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, ID) then
			ReplicatedStorage.GiveHalo:FireClient(Player)
		end
		local humanoid = Character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			wait(1)
			ReplicatedStorage.GiveHalo:FireClient(Player)
		end)
	end)
end)