Entity Attacked Trigger Reseting my Value

Started by Kako on

Topic category: Troubleshooting, bugs, and solutions

Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Entity Attacked Trigger Reseting my Value

Hello, i'm trying to make a variable that gain +1 every time the player is being attacked, but it's only going to 1 and then if i get attack it's still at 1, here is a picture of the procedure :

https://imgur.com/pjJTQki

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The problem is that you're…
Mon, 10/30/2023 - 11:40

The problem is that you're using a local variable. Local variables can only be used within a procedure, they're not permanent. Essentially, once the procedure is finished running, it deletes the variable and starts from zero.

What you want to do is go to your main workspace, and open the 'variables' tab on the left side. This lets you add global variables, which are permanent in a world's save file. You can make world variables, which are shared by all players, player-persistant variables, which are specific to each player, and player-lifetime variables, which are specific to each player and reset on death. You probably want that last one. 

Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks you so much, that…
Mon, 10/30/2023 - 16:23

Thanks you so much, that worked perfectly !