How would I make a Stamina System that requires the Player to regain the energy (Stamina) by standing still?
Depend how you do all scripts. First I would try humanoid events. I found event Running
I already got my System could I possibly show you?
Yes, why not. There is definitely way how to do it
Nice work. So you want stamina regen only when player is not moving ?
Yes thank you, it’s so the Player has no choice but to look in the darkness of the Map.
It’s possible to make if stamina get value 0 then player freeze until stamina get regenerated for 100 percent
Sorry I went for a ride with my friend.
Using the file you sent, I was able to add a simple loop which updates the position of the character.
It pinpoints the position of the player, and then adds another checkpoint for the position, which then compares the two. It is then compared, and if the .Magnitude
of the comparison is 0, meaning the player has not moved, only then will it start regenerating the stamina.
You can either make your own code based off of the description I gave, or put this in your OutSprint
LocalScript.
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local hrp = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local oldPos
local newPos
local Stamina = script.Parent.Stamina
while true do
oldPos = hrp.Position
task.wait(0.075)
newPos = hrp.Position
if Stamina.Value >= 100 then
else
if (oldPos - newPos).Magnitude == 0 then
Stamina.Value = Stamina.Value + 1
end
end
end
Thank very much it works! I will keep you updated if anything else is wrong.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.