Hunger System (2/5) 🟩

Simular to How to make a Survival Game where you NEED a few things to survive | Difficulty 4/10 by Blizzy. Have you ever wondered how to make a hunger system in your game? Well, this tutorial will show how to do that.

Why do it?

It will add more challenge to your game to get food and consume it to survive. Perfect for Survival Games.

Step One: Making the Hunger Level

You will First want to place a property device:

Then the settings. First, for simplicity, name it “Hunger”, “Hunger Level”, or somewhere along the lines. Set the property type to “Number”, then set “Initial Value” to the max hunger level. Then set “Property Scope” to “player”.

Now, we want a way to show the hunger level. We’ll use a Game Overlay for this.

Before we continue, I forgot to tell you that you need to broadcast a channel when the property changes. Go to the property’s settings, then type something like “hunger changed”, “hunger gained/loss” or somewhere along these lines.

Now, go to the Game Overlay’s settings. Then keep “Overlay Type” to “Text,” and set “Overlay Position” to where you want to display the hunger.

Then, go to the “Scope” category, then set “Content Scope” to, again, “player.”

We are done with the relay for now. Now, let’s add a Lifecycle device.

Now, go to the Lifecycle Settings. Then just set “When event occurs, transmit on” to the channel you just created earlier.

Then, go to the Game Overlay’s settings again. Then select “Blocks.”

Then, click “When receiving on channel.” Then you could just click the text box, then click what you typed earlier.

Then, click OK. You should get to somewhere where it looks somethink like this:

Now copy this (for the number, if your max hunger is not 5, the replace it with your max health):

Now, click the small X, then you are done with Step 1!

Step Two: Decreasing the Hunger

To start, just add another Lifecycle.

Then, add a Wire Repeater. Then go to it’s settings, then set “Delay” to how long you have to wait to get your hunger decrease.

Now, add another Wire Repeater, but don’t change the settings.
Screenshot 2023-12-09 8.33.17 PM
Now, add a wire from the Lifecycle you most recently placed the the first Wire Repeater you placed.

Then, check “Event occurs.”

Then, click the little X.
Now wire the first Wire Repeater to the most recent, than Vice Verca! It should look something like this:
Screenshot 2023-12-09 8.41.34 PM
You will now want to add a Vending Machine. In settings, choose a random item for “Required Item.” Then, set "Required Item Amount to 0. And for “When item purchased, transmit on,” type a new thing like “hunger loss,” “change hunger,” or somewhere along these lines.

Now go to Appearance to change these settings. Set “Visible in Game” to “No.” Then set “Sound Enabled” to “No”
Now, go to the Game Overlay to make a new script. By doing the same steps to get to the coding screen in Step 1. The only difference is that it has to be the most recent channel. Now copy this:

Now you are done with Step 2!

Step 3: Re-spawning the Player when hunger is 0

You may notice that your hunger level could be less than 0! This will fix that problem. Go to your most recent script. Then revise it to this:

Now, add a Respawn Device. And set “Respawn player when receiving on” to the most recent channel you made (not the one to decrease the hunger)
Screenshot 2023-12-09 9.24.39 PM
Ah, as you see, when you re-spawn, you keep hunger 0. revise the most recent script to this:

(For this script, if your max hunger isn’t 5, change the number it sets your property to your max hunger. to your max hunger.) And Hay Presto! You’re done with Step 3!

Step 4: Food

To add food, you first need to add an Item Spawner. Then, set “Item” to any food you want. Then, Create a new Wire Repeater with a delay of 0.1 seconds.
Screenshot 2023-12-09 9.54.49 PM
Then add another one, but don’t change the settings. Then create this setup:
Screenshot 2023-12-09 9.57.45 PM
Add a Checker, then check if the player has collected the food.

Now, in the “When check passes” area, type another phrase like “hunger increase” or somewhere along those lines. Then, add an Item Granter. Set the granted item to the food, and set the “Item Amount” to -1.
Screenshot 2023-12-09 10.06.34 PM
Wire the delayed Wire Repeater to the Checker, the wire the Checker to the Item Granter.
Screenshot 2023-12-09 10.08.03 PM
Then wire the most recent Lifecycle to the delayed Wire Repeater. Now, create a script with your most recent channel triggering it, then copy this (if your max hunger is not 5, then set all numbers in the code except for the one number that says, “1”):

Final Product:
Screenshot 2023-12-09 10.12.34 PM

Was this useful?

  • Yes
  • No
0 voters


  • 0/5 or :white_large_square:
  • 1/5 or :blue_square:
  • 2/5 or :green_square:
  • 3/5 or :yellow_square:
  • 4/5 or :red_square:
  • 5/5 or :purple_square:
  • 6/5 or :black_large_square:/:skull:
0 voters

hmm, cool. But Blizzy already made a guide on this, maybe you should credit This guide

1 Like

Nice guide! I love seeing more coders being active in the forums!


Cool guide!

he did say that it was similar

Bump! Very good guide I’m using!

It wont change the overlay.

Great guide!
Also bump!

Wait 5 days.

Oh, right. You mean after?

When do I mean after?

Like, was the bump I did earlier too early?

Yeah because I already posted and that was my bump.

Oh! Why didn’t you say so??

1 Like

Oop–nevermind. It says
17 days later…
My bad. Sorry 'bout that…

1 Like

This guide is really cool! I’m going to use it in my Minecraft game!

Also you could take away the lifecycle by just switching “broadcast value change on game start” in the property block to yes

For this part what is the outcome?