#Animation bug
1 messages · Page 1 of 1 (latest)
this script:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local UserInputService = game:GetService("UserInputService")
local Animation = script.Animation
local stamina = 100
local running = false
stamina = math.clamp(stamina,0,100)
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
local Humanoid = Character:WaitForChild("Humanoid")
local Anim = Humanoid:LoadAnimation(Animation)
Anim:Play()
running = true
Character.Humanoid.WalkSpeed = 15
while stamina > 0 and running do
stamina = stamina - 1
script.Parent:TweenSize(UDim2.new(stamina / 100,0,1,0), "Out","Linear", 0)
wait()
if stamina == 0 then
Character.Humanoid.WalkSpeed = 3
end
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
local Humanoid = Character:WaitForChild("Humanoid")
local Anima = Humanoid:LoadAnimation(Animation)
Anima:Stop()
running = false
Character.Humanoid.WalkSpeed = 3
while stamina < 100 and not running do
stamina = stamina + 1
script.Parent:TweenSize(UDim2.new(stamina / 100,0,1,0), "Out","Linear", 0)
wait()
if stamina == 0 then
Character.Humanoid.WalkSpeed = 3
end
end
end
end)
you are using :loadanimation every time. this creates a new animation track every time. so when it gets to the inputended and you loadanimation, that new animation track was never playing to start with so doing stop does nothing. fix it by calling loadanimation once, to get one animation track, and then the rest should be easy. though if you used chatgpt to write this you're gonna have a hell of a time trying 
tysm!
and do you know how to disable animation if the player is standing still (when he presses LShift)?
getpropertychangedsignal("movedirection
wdym?
listen to humanoid.movedirection when its magnitude is 0 the player isn't moving
tralarelo tralala
thanks
yup
heartbeat? and you didn't put the stamina drain in there? bruh
😙
now my character is fast even without pressing LShift, but when I'm standing, the animation doesn't work.
much better to stick to your own code that you wrote yourself
yes, but I'm new to scripting and I don't understand how to make the animation not play when I'm standing
** You are now Level 1! **
thats finnaly works