Hi, so there is a bug for my stamina script, when i use sprint, it uses animation and when I stand still the animation still goes?? here is a video explaining it
RService.RenderStepped:Connect(function()
if IsSprinting and Human.MoveDirection.Magnitude > 0 then
FOV1:Play()
if Human:GetState() == Enum.HumanoidStateType.Running or Human:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
if not SprintAnimPlaying then
YourAnim:Play()
SprintAnimPlaying = true
end
else
if SprintAnimPlaying then
YourAnim:Stop()
SprintAnimPlaying = false
end
end
else
FOV2:Play()
if SprintAnimPlaying then
YourAnim:Stop()
SprintAnimPlaying = false
end
end
end)
Try the code I just sent you I promise it will work
Also remove the FOV stuff that what I had in script
What’s the “Human” variable for the code??
Human in the code means Humanoid
I mean all the variables for the script
local TService = game:GetService('TweenService')
local IService = game:GetService('UserInputService')
local Camera = game.Workspace.CurrentCamera
local RService = game:GetService('RunService')
local Human = script.Parent:WaitForChild('Humanoid', 3)
local Anims = script:WaitForChild('Anims')
local Vals = script:WaitForChild('Vals')
Hey, I wanted to add the script like that to my script. I tried but nothing worked
--= Variables =--
local camera = game.Workspace.CurrentCamera
local TweeningService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UIS = game:GetService('UserInputService')
local Bar = script.Parent:WaitForChild('STMBackground'):WaitForChild('Bar')
local player = game.Players.LocalPlayer
local debounce = true
local NormalWalkSpeed = 13
local NewWalkSpeed = 16
local power = 10
local sound = script.Parent["Heavy Breathing ( Man )"]
local sprinting = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character
--= Tween Functions =--
-- sprinting
local FOVChanges = {
FieldOfView = 90
}
local TweenInformation = TweenInfo.new(
1, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out, --easing Direction
0, --repitition time
false, --reverse?
0 --delay
)
local tween = TweeningService:Create(camera,TweenInformation,FOVChanges)
-- walking
local FOVChanges2 = {
FieldOfView = 70
}
local TweenInformation2 = TweenInfo.new(
1, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out, --easing Direction
0, --repitition time
false, --reverse?
0 --delay
)
local tween2 = TweeningService:Create(camera,TweenInformation2,FOVChanges2)
--= Functions =--
UIS.InputBegan:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
character.Humanoid.WalkSpeed = NewWalkSpeed
sprinting = true
sound:Play()
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://6437730800'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
while power > 0 and sprinting do
power = power - .05
Bar.Size = UDim2.new(power / 10, 0, 1, 0)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 42, 42), 0.001)
tween:Play()
wait()
if power <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
tween2:Play()
PlayAnim:Pause()
end
end
end
end)
UIS.InputEnded:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
character.Humanoid.WalkSpeed = NormalWalkSpeed
sprinting = false
PlayAnim:Stop()
sound:Pause()
while power < 10 and not sprinting do
power = power + .02
Bar.Size = UDim2.new(power / 10, 0, 1, 0)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 166, 11), 0.001)
tween2:Play()
wait()
if power <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)
Add a new command named IsWorking.
And make the new instance work with it
but I don’t really understand what your trying to do