i need help to stop the animation playing while sprinting:
block of code:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = nil
local camera = game.Workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Configuration = require(game.ReplicatedStorage.Modules:WaitForChild("Configuration"))
function IsWalking()
if humanoid.MoveDirection.Magnitude > 0 then
return true
else
return false
end
end
UIS.InputBegan:Connect(function(key, proccess)
if key.KeyCode == Configuration.RunKey then
if IsWalking() then
animation = humanoid:LoadAnimation(script.Animation)
animation:Play(0.1, 1, 2)
humanoid.JumpPower = 0
humanoid.WalkSpeed = humanoid.WalkSpeed + 9
TweenService:Create(camera, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FieldOfView = camera.FieldOfView + 10}):Play()
end
end
end)
UIS.InputEnded:Connect(function(key, proccess)
if key.KeyCode == Configuration.RunKey then
animation:Stop()
humanoid.JumpPower = 50
humanoid.WalkSpeed = humanoid.WalkSpeed - 9
TweenService:Create(camera, TweenInfo.new(0.2 , Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FieldOfView = camera.FieldOfView - 10}):Play()
end
end)
video:
External Media