ok. i’ve been working on a sprint script recently and after implementing some stamina stuff, this bug was present before but it got even more noticable. whenever i jump, the fall animation is supposed to play, it does, but then it constantly replays even though it’s not set on loop in the animation maker.
could i get some help? here is the script:
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Stamina = 100
local Running = false
Stamina = math.clamp(Stamina, 0, 100)
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Running = true
Character.Humanoid.WalkSpeed = 24
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://7384132764'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
while Stamina > 0 and Running do
Stamina = Stamina - 1
script.Parent:TweenSize(UDim2.new(Stamina/ 100, 0, 1, 0), "Out", "Linear",0)
wait(0.06)
if Stamina == 0 then
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
end
end
end
if input.KeyCode == Enum.KeyCode.Space then
local JumpAnim = Instance.new('Animation')
local FallAnim = Instance.new('Animation')
JumpAnim.AnimationId = 'rbxassetid://7391963123'
FallAnim.AnimationId = 'rbxassetid://7397288802'
FallAnimPlay = Character.Humanoid:LoadAnimation(FallAnim)
JumpAnimPlay = Character.Humanoid:LoadAnimation(JumpAnim)
PlayAnim:Stop()
JumpAnimPlay:Play()
while Stamina > 0 and Running do
wait(0.06)
if Stamina == 0 then
Character.Humanoid.WalkSpeed = 16
JumpAnimPlay:Stop()
FallAnimPlay:Stop()
end
end
end
if (JumpAnimPlay) then
wait(JumpAnimPlay.Length)
FallAnimPlay:Play()
wait(FallAnimPlay.Length)
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Running = false
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
end
if input.KeyCode == Enum.KeyCode.Space then
JumpAnimPlay:Stop()
FallAnimPlay:Stop()
PlayAnim:Play()
end
while Stamina < 100 and not Running do
Stamina = Stamina + 1
script.Parent:TweenSize(UDim2.new(Stamina/ 100, 0, 1, 0), "Out", "Linear",0)
wait(0.06)
if Stamina == 0 then
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
end
end
end)
here is a video of what happens:
https://i.gyazo.com/2c55384ae356423f298e439433dfbd91.mp4
hope it helps! thank you for reading this!