(Note: game is filtered enabled) (Note: staminabar goes down but doesnt go back up) (Note: no errors in output)
-- Variables
local replicatedStorage = game:GetService("ReplicatedStorage")
local sprintEvent = replicatedStorage:WaitForChild("sprintEvent")
local sprintEnded = replicatedStorage:WaitForChild("sprintEnded")
local userInput = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local humanoid = plr.Character:WaitForChild("Humanoid")
local staminaFolder = plr:WaitForChild("stamFolder")
local stamina = staminaFolder:WaitForChild("stamina")
local staminaBar = script.Parent.background.staminabar
local staminaGui = script.Parent
local isSprinting = false
local canSprint = true
-- Scripting
userInput.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
isSprinting = true
sprintEvent:FireServer()
while isSprinting and stamina.Value > 0 do
staminaBar:TweenSize(UDim2.new(stamina.Value * 0.01, 0, 1, 0), "Out", "Sine", .01)
stamina.Value = stamina.Value - 1
wait(.2)
end
if humanoid.WalkSpeed == 16 then
isSprinting = false
end
end
end)
userInput.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
isSprinting = false
sprintEnded:FireServer()
while isSprinting and stamina.Value < 100 do
stamina.Value = stamina.Value + 1
staminaBar:TweenSize(UDim2.new(stamina.Value * 0.01, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .01)
end
if stamina.Value >= 33 then
canSprint = true
elseif stamina.Value == 0 then
canSprint = false
end
end
end)
