.Heartbeat not running when using Maid

  1. What do you want to achieve? Keep it simple and clear!
    On my script Heartbeat is not running despite prints showing up in the output before. I even added prints inside of the Heartbeat, but they do not show up.

  2. What is the issue? Include screenshots / videos if possible!
    The Heartbeat doesn’t work after 2 times the flag is picked up.
    https://gyazo.com/0014bf7e12bbeffbc9e32c96094fe845 - The code shown here

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried searching, I tried using Humanoid.Died (that didn’t work either), I asked my other developer friends but they couldn’t figure out either. So now I am here.
    The Humanoid is gained from Hit.Parent, and then finding Humanoid in it.
    No errors show up in the script at all, what am I doing wrong here?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Code here:

if Humanoid and Humanoid.Health > 0 and Player and Player:IsA("Player") and (Player.Team ~= TEAM.Value or Player.Neutral and TEAM.Value ~= nil and TEAM.Value:IsA("Team")) then
			print("enemy team picked up")
			local CarryTag = Instance.new("BoolValue", Part.Parent)
			CarryTag.Name = "CarryingOpponentFlag"
			CarryTag.Value = true
			HeartbeatMaid.OnDeath = game:GetService("RunService").Heartbeat:Connect(function()
				print(Humanoid.Health)
				if Humanoid.Health <= 0 or not Humanoid.Parent:FindFirstChild("CarryingOpponentFlag") then
					print("Target died")
					HeartbeatMaid:DoCleaning()

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.

1 Like

A couple things first, don’t link screenshots or images as sources of code. Please use the lua code blocks and copy(ctrl-c) and paste(ctrl-v) the code.

What prints specifically stop showing up? All three of them?

The “Humanoid.Health” print doesn’t show up because the Heartbeat doesn’t work, and “Target died” did not print.
The only print that shows up is “enemy team picked up”

my guess is that the OnDeath isn’t firing. try seeing if it is firing correctly

Yes, the .OnDeath was never firing, but in my other scripts (the original flags that are to be picked up by the opposing team) they work. This script is located in a different flag called DroppedFlag that drops when somebody dies with the two original flags. I’ve tried GetPropertyChanged with the health as well but that doesn’t fire either

ChangedMaid.HealthChanged = Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
				print(Humanoid.Health)
				if Humanoid.Health <= 0 or not Humanoid.Parent:FindFirstChild("CarryingOpponentFlag") then
					print("Target died")
					ChangedMaid:DoCleaning()
					task.wait(1)

try using Humanoid.Died instead

20 charsssssssssssssssssss

I changed it back to Humanoid.Died but it did not work still. I also added a print that came after the CarryTag value and it shows up in output