I found ! Thank you for the timer behavior tips !
The "How to" for who need the same thing (I don't put any screenshot or project file because i'm not at home, I just have the real "Potato Internet" here.)
Create your stamina bar and a global variable named "Stamina". You can found some tutorial on the Internet for making a stamina bar who moved with your "Stamina" variable.
I set the global variable "Stamina" to 100.
My stamina bar have 4 behavior : The "Pin" behavior because my stamina bar follow the player. The "Timer" behavior for the little timing before it start regenerating. And two "Fade" behavior, one for the Fade In, the other one for the fade out (I want my bar to be invisible after 1.5 seconds if the stamina is full).
For the two "Fade" behavior, name the first one "Fade_In" with the settings : "Yes", "0.5", "0", "0", "No". And the other one named "Fade_Out" with the settings : "No", "0", "1", "1", "After fade out".
And the code :
If Keybord "Maj" is down, AND if "Stamina" over 0, AND if the speed of the player is under the walk speed. -----> Set the player speed to "run speed", subtract the stamina (0.7 for me). stop the timer (inser your timer tag, can be anything, that doesn't matter), and desactivate the "Start_Stamina_Regen" group (we gonna create it later).
If Keybord "Maj" is released -----> Set player speed to "walk speed".
If "Stamina" (global variable) is under 100, AND the speed of the player is under the "run speed" -----> Start the timer of the stamina bar for 3 seconds, "Once" with the tag "Stamina_Regen"
If "On Timer "Stamina_Regen"" condition is true ----> set group "Start_Stamina_Regen" activated.
CREATE A NEW GROUP named "Start_Stamina_Regen" (activated by default).
put in the new group : : Every 0.05 seconds, add 4 to "Stamina" (global variable).
(in no group this time) If "Stamina" (global variable) is equal or over 100 -----> Set "Stamina" to 100, set group "Start_Stamina_Regen" to deactivated, Call the function "Stamina_Bar_Fadeout" (we gonna create the function later). set group "If_StaminaUnder100" to activated (we gonna create the group later).
If "Stamina" (global variable) is under 0 ------> Set "Stamina" to 0, set the player speed to "Walk speed".
CREATE A NEW GROUP named "If_StaminaUnder100"
put in it : if "Stamina" under 100 ------> Call function "Stamina_Bar_Start" (we gonna create the function later), and set the group "If_StaminaUnder100" to deactivated.
(in no group this time) : on function "Stamina_Bar_Start" ----> Create the stamina bar were you want with your settings, you can Pin it on other objects like me if you want. and Start the "Fade_In" behavior.
On function "Stamina_Bar_FadeOut" -----> Start the "Fade_Out" behavior.
Sorry for the long post.