HP not reseting

For some reason, when the player dies, and respawns, it doesn’t reset the HP.
It stays at 0, and when the player takes damage, they automatically die.
Here is the code:


Basically, the player clicks the “respawn” button and gets teleported to the start of the level without resetting the level. It’s supposed to reset the HP, and it does.
But the game still thinks I have 0 HP.
Here is the game:Flowlab Game Creator - Survival in the Wilderness
The code is in the player.
Here is the Forum if you want o hear updates:Survival in the Wilderness Devlog! - #34 by Truce2017
Thank you!

1 Like

First you should make your “Health” value into a global. I really can’t tell which number is the one that’s not working.

When looking through your coding I saw that you have like three different health bits, at least that’s what it looks like, I would recommend making it one even if it results in a messier web. Next there are so many parts that I don’t get, maybe label some numbers?

1 Like

Ok I’ll do that now.

1 Like

I did it.
Now I labeled most of the code in the HP bundle to show people what is what.
I hope someone can help :cry:

There is no 'get; input in the health “Max HP” Number. The number is not reading.


It should look like this.

No, the number still outputs with the + input. You don’t need the additional input

2 Likes

Looking through it doesn’t reset because there is no load level current level chunk, you have a position instead, if you wanted to do the position you’d have to make it so when they die you add 20 health back

2 Likes

Ha! Sorry, I thought he was using the set input!

So, I think I found the problem, if I am understanding this right. When the player dies you need the “Max HP” number to rest to 20. I will get a screenshot.

Here;

Code;

Click Here

{"data":{"behavior":{"v":"2","nodes":[{"delay":10,"count":0,"version":2,"inputCount":3,"outputCount":1,"name":"Timer","behaviorType":"logic.triggers.Timer","x":-540,"y":96,"group":"c9b3cf6d64f06449","id":"a70533d8c97ea24e"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-360,"y":96,"group":"c9b3cf6d64f06449","id":"a70533d840d3914c","targetId":0,"prop":"y"},{"gateVal":1000,"mode":"greater than","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter","x":-180,"y":96,"group":"c9b3cf6d64f06449","id":"a70533d81ea5e841"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":180,"y":96,"group":"c9b3cf6d64f06449","id":"a70533d88cc4134e","notes":"TP to choords","n_o":1,"startVal":0,"tag":"heal","roundMode":1},{"inputCount":4,"outputCount":2,"name":"Position","behaviorType":"logic.properties.Position","x":360,"y":96,"group":"c9b3cf6d64f06449","id":"a70533d928cd0c42","pixelUnits":true,"resetVelocity":false},{"inputCount":4,"outputCount":4,"name":"Label","behaviorType":"logic.hud.Label2","x":630,"y":8,"group":"c9b3cf6d64f06449","id":"cf35db0a1d0c0445","notes":"HP display","n_o":1,"text":"20","textColor":15469609,"fontName":"oduda","scale":10,"textAlign":"left","maxWidth":0,"xO":440,"yO":359,"pin":false,"alpha":100,"kerning":0},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-180,"y":-16,"group":"c9b3cf6d64f06449","id":"cf3620788923584c","notes":"Damage taken by zombie","n_o":1,"startVal":-3,"tag":"","roundMode":1},{"inputCount":0,"outputCount":1,"name":"Collision","behaviorType":"logic.triggers.Collision","x":-360,"y":0,"group":"c9b3cf6d64f06449","id":"cf4f27bfeca1f748","targetClassId":17871278,"targetEntityId":0,"collisionFilter":15,"collideWithEntity":false,"delay":0},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":90,"y":0,"group":"c9b3cf6d64f06449","id":"cf4f6ae08264334f","notes":"Max HP","n_o":1,"startVal":20,"tag":"","roundMode":1},{"gateVal":1,"mode":"less than","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":270,"y":-112,"group":"c9b3cf6d64f06449","id":"d3b6bca9e94aab4a"},{"inputCount":2,"outputCount":2,"name":"Pause","behaviorType":"logic.gameflow.Pause","x":450,"y":-112,"group":"c9b3cf6d64f06449","id":"d3b7418677577549"},{"comp_x":142,"comp_y":185,"inputCount":2,"outputCount":1,"name":"Alert","behaviorType":"logic.hud.Alert","x":630,"y":-112,"group":"c9b3cf6d64f06449","id":"d3b79b19d5111445","header":"You have died","message":"Death to zombie","buttonLabel":"Respawn","bgColor":15337496,"btnColor":394758,"textColor":15856113},{"inputCount":0,"outputCount":1,"name":"Collision","behaviorType":"logic.triggers.Collision","x":-360,"y":-128,"group":"c9b3cf6d64f06449","id":"d3cd78092a4f9e4d","targetClassId":17634813,"targetEntityId":0,"collisionFilter":1,"collideWithEntity":false,"delay":0},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":90,"y":-136,"group":"c9b3cf6d64f06449","id":"d3cd7809a497ff43","notes":"Max HP","n_o":1,"startVal":20,"tag":"","roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-180,"y":-144,"group":"c9b3cf6d64f06449","id":"d3cd7809e4ec7448","notes":"Damage taken by sand","n_o":0,"startVal":-1,"tag":"","roundMode":1},{"gateVal":1,"mode":"less than","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":270,"y":-224,"group":"c9b3cf6d64f06449","id":"d3cd780aa6621549"},{"inputCount":2,"outputCount":2,"name":"Pause","behaviorType":"logic.gameflow.Pause","x":450,"y":-224,"group":"c9b3cf6d64f06449","id":"d3cd780ae1cba34f"},{"comp_x":142,"comp_y":185,"inputCount":2,"outputCount":1,"name":"Alert","behaviorType":"logic.hud.Alert","x":630,"y":-224,"group":"c9b3cf6d64f06449","id":"d3cd782811f02947","header":"You have died","message":"Suffacated in sand","buttonLabel":"Respawn","bgColor":15337496,"btnColor":394758,"textColor":15856113},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":990,"y":-152,"group":"c9b3cf6d64f06449","id":"d98a10656d792b4f","startVal":0,"tag":"","roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":1170,"y":-152,"group":"c9b3cf6d64f06449","id":"d98a4e43cf8ef44c","notes":"Reset HP","n_o":1,"startVal":20,"tag":"","roundMode":1},{"inputCount":0,"outputCount":1,"name":"Mailbox","behaviorType":"logic.components.Mailbox","x":0,"y":208,"group":"c9b3cf6d64f06449","id":"da4b8dc55130fb4a","msg":"heal"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":360,"y":208,"group":"c9b3cf6d64f06449","id":"da4bb9c60fe62046","notes":"Max HP","startVal":20,"tag":"","roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":180,"y":216,"group":"c9b3cf6d64f06449","id":"da4bba5a8495b241","notes":"HP healed by pork","startVal":5,"tag":"","roundMode":1},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-90,"y":-312,"group":"c9b3cf6d64f06449","id":"ddc804a0a752f84b","notes":"ADD THIS! ","n_o":1,"startVal":20,"tag":"","roundMode":1}],"links":[{"input_id":"a70533d840d3914ci0","output_id":"a70533d8c97ea24eo0"},{"input_id":"a70533d840d3914ci0","output_id":"a70533d8c97ea24eo0"},{"input_id":"a70533d81ea5e841i0","output_id":"a70533d840d3914co0"},{"input_id":"a70533d81ea5e841i0","output_id":"a70533d840d3914co0"},{"input_id":"a70533d88cc4134ei1","output_id":"a70533d81ea5e841o0"},{"input_id":"a70533d88cc4134ei1","output_id":"a70533d81ea5e841o0"},{"input_id":"a70533d88cc4134ei1","output_id":"d3cd782811f02947o0"},{"input_id":"a70533d88cc4134ei1","output_id":"d3b79b19d5111445o0"},{"input_id":"a70533d928cd0c42i0","output_id":"a70533d88cc4134eo0"},{"input_id":"a70533d928cd0c42i1","output_id":"a70533d88cc4134eo0"},{"input_id":"a70533d928cd0c42i0","output_id":"a70533d88cc4134eo0"},{"input_id":"a70533d928cd0c42i1","output_id":"a70533d88cc4134eo0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"cf4f6ae08264334fo0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"d3cd7809a497ff43o0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"d98a4e43cf8ef44co0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"da4bb9c60fe62046o0"},{"input_id":"cf3620788923584ci1","output_id":"cf4f27bfeca1f748o0"},{"input_id":"cf4f6ae08264334fi2","output_id":"cf3620788923584co0"},{"input_id":"cf3620788923584ci1","output_id":"cf4f27bfeca1f748o0"},{"input_id":"cf4f6ae08264334fi0","output_id":"ddc804a0a752f84bo0"},{"input_id":"cf4f6ae08264334fi2","output_id":"cf3620788923584co0"},{"input_id":"d3b6bca9e94aab4ai1","output_id":"cf4f6ae08264334fo0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"cf4f6ae08264334fo0"},{"input_id":"d3b6bca9e94aab4ai1","output_id":"cf4f6ae08264334fo0"},{"input_id":"d3b7418677577549i0","output_id":"d3b6bca9e94aab4ao0"},{"input_id":"d3b7418677577549i0","output_id":"d3b6bca9e94aab4ao0"},{"input_id":"d3b7418677577549i1","output_id":"d3b79b19d5111445o0"},{"input_id":"d3b79b19d5111445i0","output_id":"d3b7418677577549o0"},{"input_id":"d3b79b19d5111445i0","output_id":"d3b7418677577549o0"},{"input_id":"d98a10656d792b4fi1","output_id":"d3b79b19d5111445o0"},{"input_id":"d3b7418677577549i1","output_id":"d3b79b19d5111445o0"},{"input_id":"a70533d88cc4134ei1","output_id":"d3b79b19d5111445o0"},{"input_id":"d3cd7809e4ec7448i1","output_id":"d3cd78092a4f9e4do0"},{"input_id":"d3cd7809a497ff43i0","output_id":"ddc804a0a752f84bo0"},{"input_id":"d3cd7809a497ff43i2","output_id":"d3cd7809e4ec7448o0"},{"input_id":"d3cd780aa6621549i1","output_id":"d3cd7809a497ff43o0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"d3cd7809a497ff43o0"},{"input_id":"d3cd7809e4ec7448i1","output_id":"d3cd78092a4f9e4do0"},{"input_id":"d3cd7809a497ff43i2","output_id":"d3cd7809e4ec7448o0"},{"input_id":"d3cd780aa6621549i1","output_id":"d3cd7809a497ff43o0"},{"input_id":"d3cd780ae1cba34fi0","output_id":"d3cd780aa6621549o0"},{"input_id":"d3cd780ae1cba34fi0","output_id":"d3cd780aa6621549o0"},{"input_id":"d3cd780ae1cba34fi1","output_id":"d3cd782811f02947o0"},{"input_id":"d3cd782811f02947i0","output_id":"d3cd780ae1cba34fo0"},{"input_id":"d3cd782811f02947i0","output_id":"d3cd780ae1cba34fo0"},{"input_id":"d3cd780ae1cba34fi1","output_id":"d3cd782811f02947o0"},{"input_id":"d98a10656d792b4fi1","output_id":"d3cd782811f02947o0"},{"input_id":"a70533d88cc4134ei1","output_id":"d3cd782811f02947o0"},{"input_id":"d98a10656d792b4fi1","output_id":"d3cd782811f02947o0"},{"input_id":"d98a10656d792b4fi1","output_id":"d3b79b19d5111445o0"},{"input_id":"d98a4e43cf8ef44ci2","output_id":"d98a10656d792b4fo0"},{"input_id":"d98a4e43cf8ef44ci2","output_id":"d98a10656d792b4fo0"},{"input_id":"ddc804a0a752f84bi1","output_id":"d98a4e43cf8ef44co0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"d98a4e43cf8ef44co0"},{"input_id":"da4bba5a8495b241i1","output_id":"da4b8dc55130fb4ao0"},{"input_id":"da4bb9c60fe62046i2","output_id":"da4bba5a8495b241o0"},{"input_id":"cf35db0a1d0c0445i0","output_id":"da4bb9c60fe62046o0"},{"input_id":"da4bba5a8495b241i1","output_id":"da4b8dc55130fb4ao0"},{"input_id":"da4bb9c60fe62046i2","output_id":"da4bba5a8495b241o0"},{"input_id":"ddc804a0a752f84bi1","output_id":"d98a4e43cf8ef44co0"},{"input_id":"d3cd7809a497ff43i0","output_id":"ddc804a0a752f84bo0"},{"input_id":"cf4f6ae08264334fi0","output_id":"ddc804a0a752f84bo0"}]}}}