i was tried this befpre it's work but sometimes it not run the animation

local mouse = game.Players.LocalPlayer:GetMouse()
local running = false
local s = ""

function getTool()	
	for _, kid in ipairs(script.Parent:GetChildren()) do
		if kid.className == "Tool" then return kid end
	end
	return nil
end

mouse.KeyDown:connect(function (key)
	key = string.lower(key)
	if key == "w" or key == "" then
		s = s.."w"
		delay(0.2,function ()
			if s ~= "ww" then
				s = ""
			end
		end)
		if s == "ww" then
			s = ""
			running = true
			local keyConnection = mouse.KeyUp:connect(function (key)
				if key == "w" or key == "" then
					running = false
				end
			end)
			script.Parent.Animate.Disabled = true
			delay(0,function ()
				local stuff = script.Parent.Torso:GetChildren()
				for i = 1,#stuff do
					if stuff[i]:IsA("Motor6D") and stuff[i].Name ~= "Neck" then
						stuff[i].MaxVelocity = 0.3
					end
				end
				while running == true do
					for i = 1,#stuff do
						if stuff[i]:IsA("Motor6D") and stuff[i].Name ~= "Neck" then
							stuff[i].DesiredAngle = 1.5
						end
					end
					if running == true then
						wait(0.5)
					end
					for i = 1,#stuff do
						if stuff[i]:IsA("Motor6D") and stuff[i].Name ~= "Neck" then
							stuff[i].DesiredAngle = -1.5
						end
					end
					if getTool() then
						script.Parent.Torso["Right Shoulder"].DesiredAngle = 1.57
					end
					if running == true then
						wait(0.5)
					end
				end
				script.Parent.Animate.Disabled = false
			end)
			for i = 1,5 do
				game.Workspace.CurrentCamera.FieldOfView = (70+(i*2))
				wait()
			end
			game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 24
			repeat wait () until running == false
			keyConnection:disconnect()
			game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
			for i = 1,5 do
				game.Workspace.CurrentCamera.FieldOfView = (80-(i*2))
				wait()
			end
		end
	end
end)