I've got a bit of code that enables the user to press shift to run even faster, jump higher, and leave behind a trail. How would I make this operate on a "stamina meter" value so that for the time they're moving and holding shift a value depletes?
Here's what I've got.
super_sprint = 48 dash_jump = 90 MyMouse = game.Players.localPlayer:GetMouse() Player = game.Players.localPlayer trail = Player.Character.HumanoidRootPart:FindFirstChild("Trail") MyMouse.KeyDown:connect(function(key) if (key:byte() == 48) then local human = Player.Character:FindFirstChild("Humanoid") human.WalkSpeed = super_sprint human.JumpPower = dash_jump trail.Enabled = true end end) MyMouse.KeyUp:connect(function(key) if (key:byte() == 48) then local human = Player.Character:FindFirstChild("Humanoid") human.WalkSpeed = 32 human.JumpPower = 75 trail.Enabled = false end end)
I believe I have an answer for this. If it doesn't meet requirements please let me know.
I have to use a FOR loop otherwise incrementing values would be cumbersome.
How it works:
for i = 1, maxStam do --maxStam is a variable that contains the **STAMINA OF THE INDIVIDUAL** please read on stam = i end
I know this isn't a lot but it will work if you use it wisely. Goodbye.