i dont know why but this code dosent work for some reason
local staminaFrame = script.Parent
local maxStamina = 500
local minStamina = 0
local staminaChange = 1
local changeInterval = 0.05
local function reduceStamina()
local newStamina = math.max(staminaFrame.Size.X.Scale - staminaChange, minStamina)
staminaFrame.Size = UDim2.new(newStamina, 0, staminaFrame.Size.Y.Scale, 0)
end
local function increaseStamina()
local newStamina = math.min(staminaFrame.Size.X.Scale + staminaChange, maxStamina)
staminaFrame.Size = UDim2.new(newStamina, 0, staminaFrame.Size.Y.Scale, 0)
end
local function onInputBegan(inputObject)
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
while wait(changeInterval) and inputObject.UserInputState == Enum.UserInputState.Begin do
reduceStamina()
end
end
end
local function onInputEnded(inputObject)
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
while wait(changeInterval) and inputObject.UserInputState == Enum.UserInputState.End do
increaseStamina()
end
end
end
game.Players.LocalPlayer:GetMouse().KeyDown:connect(onInputBegan)
game.Players.LocalPlayer:GetMouse().KeyUp:connect(onInputEnded)
(Code was made by AI)