hello!
-
What do you want to achieve? Keep it simple
-
What is the issue? its not restoring/adding the 0.3 to the value
-
What solutions have you tried so far? asked my friend he said its fine, changed the code a bit
heres the code
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local RunS = game:GetService("RunService")
local Plr = Players.LocalPlayer
local Chr = Plr.Character or Plr.CharacterAdded:Wait()
local Anims = RS.Animations
local RunTrack = Chr.Humanoid.Animator:LoadAnimation(Anims.RunAnim)
local Main = StarterGui.Main
local StaminaUI = Main.StaminaUI
local StaminaValue = Main.StaminaValue
local Running = false
UIS.InputBegan:Connect(function(Input)
if StaminaValue.Value < 5 then return end
if Input.KeyCode == Enum.KeyCode.LeftShift then
Chr.Humanoid.WalkSpeed = 30
Chr.Humanoid.JumpPower = 0
Running = true
RunTrack:Play()
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
Chr.Humanoid.WalkSpeed = 16
Chr.Humanoid.JumpPower = 35
Running = false
RunTrack:Stop()
end
end)
while wait(0.1) do
print(Running)
print(StaminaValue.Value)
if Running == true then
StaminaValue.Value -= 1
else
StaminaValue.Value += 0.3
end
if StaminaValue.Value < 5 then
Chr.Humanoid.WalkSpeed = 16
RunTrack:Stop()
end
end
thank you!